Skip to content

Commit

Permalink
Rector fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
idmarinas committed Dec 2, 2024
1 parent 29c7102 commit aed3179
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/Command/RegenerateAppSecretCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ protected function execute (InputInterface $input, OutputInterface $output): int
$secret = bin2hex(random_bytes($length));

if ($showValue) {
$io->success("New $key was generated: $secret");
$io->success(sprintf('New %s was generated: %s', $key, $secret));

return Command::SUCCESS;
}
Expand All @@ -72,17 +72,17 @@ protected function execute (InputInterface $input, OutputInterface $output): int
$str = file_get_contents($file);
$fs = new Filesystem();

$pattern = "/^(?<secret>$key=.+)$/m";
$pattern = sprintf('/^(?<secret>%s=.+)$/m', $key);
preg_match($pattern, $str, $matches);

if (isset($matches['secret']) && is_string($matches['secret'])) {
$str = preg_replace("/{$matches['secret']}/", "{$key}={$secret}", $str);
$str = preg_replace(sprintf('/%s/', $matches['secret']), sprintf('%s=%s', $key, $secret), $str);

$fs->dumpFile($file, $str);

$io->success("New {$key} was generated: {$secret}");
$io->success(sprintf('New %s was generated: %s', $key, $secret));
} else {
$io->warning("Not find {$key} in file '{$file}'");
$io->warning(sprintf("Not find %s in file '%s'", $key, $file));
}

return Command::SUCCESS;
Expand Down
4 changes: 2 additions & 2 deletions src/Traits/Tool/VersionTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ public function convertVersionToString (int $version): string
$version = substr_replace($version, '', -4);
$major = (int)substr($version, -4);

return "{$major}.{$minor}.{$path}";
return sprintf('%d.%d.%d', $major, $minor, $path);
}

/** Convert string version like 1.0.0 to 100000000 */
public function convertVersionToInt (string $version): int
{
$re = '^(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$';

preg_match_all("/$re/m", $version, $matches, PREG_SET_ORDER, 0);
preg_match_all(sprintf('/%s/m', $re), $version, $matches, PREG_SET_ORDER, 0);
$matches = $matches[0];

$major = str_pad($matches['major'], 4, 0, STR_PAD_LEFT);
Expand Down

0 comments on commit aed3179

Please sign in to comment.