Skip to content

Commit

Permalink
Merge pull request #66 from brociani/fix-ci
Browse files Browse the repository at this point in the history
fix(ci): use sprintf native function
  • Loading branch information
mremi authored Aug 1, 2024
2 parents e395245 + b07e5e3 commit 22a0fd4
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ CHANGELOG
master
------

* todo...
* Force use of sprintf native function

v3.1.0
------
Expand Down
6 changes: 3 additions & 3 deletions Command/EncryptCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$method = $input->getOption('method');

if (!\in_array($method, openssl_get_cipher_methods())) {
throw new \InvalidArgumentException(sprintf('The method "%s" is not available. Please choose one of the following methods: %s', $method, implode(', ', openssl_get_cipher_methods())));
throw new \InvalidArgumentException(\sprintf('The method "%s" is not available. Please choose one of the following methods: %s', $method, implode(', ', openssl_get_cipher_methods())));
}

$output->writeln(sprintf("<info>Encryption parameters:</info>\nText:\t\"%s\"\nSecret:\t\"%s\"\nMethod:\t\"%s\"\n", $text, $secret, $method));
$output->writeln(\sprintf("<info>Encryption parameters:</info>\nText:\t\"%s\"\nSecret:\t\"%s\"\nMethod:\t\"%s\"\n", $text, $secret, $method));
$encryptor = new Encryptor($method, $secret);
$output->writeln(sprintf('<info>Encrypted text:</info> %s', $encryptor->encrypt($text)));
$output->writeln(\sprintf('<info>Encrypted text:</info> %s', $encryptor->encrypt($text)));

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion Controller/LogsAdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private function getDecryptedResults(string $content): array

if (!empty($matches)) {
foreach ($matches as $index => $match) {
$results[sprintf('%s_%d', $match[1], $index + 1)] = json_decode($this->encryptor->decrypt($match[2]), true);
$results[\sprintf('%s_%d', $match[1], $index + 1)] = json_decode($this->encryptor->decrypt($match[2]), true);
}
} else {
$results['result'] = json_decode($this->encryptor->decrypt($content), true);
Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/EnvVarEncryptedProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function getEnv(string $prefix, string $name, \Closure $getEnv): string
return $this->encryptor->decrypt($getEnv($name));
}

throw new RuntimeException(sprintf('Unsupported env var prefix "%s".', $prefix));
throw new RuntimeException(\sprintf('Unsupported env var prefix "%s".', $prefix));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions Encryptor/Encryptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function encrypt(string $data): string
$cipherText = openssl_encrypt($data, $this->method, $this->secret, OPENSSL_RAW_DATA, $iv);

if ($cipherText === false) {
throw new EncryptionException(sprintf('Unexpected failure in openssl_encrypt: %s', openssl_error_string()));
throw new EncryptionException(\sprintf('Unexpected failure in openssl_encrypt: %s', openssl_error_string()));
}

return base64_encode($iv.$cipherText);
Expand All @@ -76,7 +76,7 @@ public function decrypt(string $data): string
$decrypt = openssl_decrypt($cipherText, $this->method, $this->secret, OPENSSL_RAW_DATA, $iv);

if ($decrypt === false) {
throw new EncryptionException(sprintf('Unexpected failure in openssl_decrypt: %s', openssl_error_string()));
throw new EncryptionException(\sprintf('Unexpected failure in openssl_decrypt: %s', openssl_error_string()));
}

return $decrypt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function testLoadWithInvalidConfigs(array $configs, string $exceptionMess
try {
$this->extension->load($configs, $this->containerBuilder);

$this->fail(sprintf('Expecting %s with message \'%s\'', InvalidConfigurationException::class, $exceptionMessage));
$this->fail(\sprintf('Expecting %s with message \'%s\'', InvalidConfigurationException::class, $exceptionMessage));
} catch (InvalidConfigurationException $e) {
$this->assertMatchesRegularExpression($exceptionMessage, $e->getMessage());
}
Expand Down

0 comments on commit 22a0fd4

Please sign in to comment.