8000 [Console] replace method by const · symfony/symfony@d0f6b98 · GitHub
[go: up one dir, main page]

Skip to content

Commit d0f6b98

Browse files
[Console] replace method by const
1 parent 38aad7d commit d0f6b98

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

src/Symfony/Component/Uid/Command/GenerateUlidCommand.php

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@
2323

2424
class GenerateUlidCommand extends Command
2525
{
26+
private const FORMAT_OPTIONS = [
27+
'base32',
28+
'base58',
29+
'rfc4122',
30+
];
31+
2632
protected static $defaultName = 'ulid:generate';
2733
protected static $defaultDescription = 'Generate a ULID';
2834

@@ -87,7 +93,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
8793

8894
$formatOption = $input->getOption('format');
8995

90-
if (\in_array($formatOption, $this->getAvailableFormatOptions())) {
96+
if (\in_array($formatOption, self::FORMAT_OPTIONS)) {
9197
$format = 'to'.ucfirst($formatOption);
9298
} else {
9399
$io->error(sprintf('Invalid format "%s", did you mean "base32", "base58" or "rfc4122"?', $input->getOption('format')));
@@ -112,16 +118,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
112118
public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
113119
{
114120
if ($input->mustSuggestOptionValuesFor('format')) {
115-
$suggestions->suggestValues($this->getAvailableFormatOptions());
121+
$suggestions->suggestValues(self::FORMAT_OPTIONS);
116122
}
117123
}
118-
119-
private function getAvailableFormatOptions(): array
120-
{
121-
return [
122-
'base32',
123-
'base58',
124-
'rfc4122',
125-
];
126-
}
127124
}

0 commit comments

Comments
 (0)
0