diff options
Diffstat (limited to 'vendor/symfony/console/Completion/CompletionSuggestions.php')
-rw-r--r-- | vendor/symfony/console/Completion/CompletionSuggestions.php | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/vendor/symfony/console/Completion/CompletionSuggestions.php b/vendor/symfony/console/Completion/CompletionSuggestions.php new file mode 100644 index 0000000..549bbaf --- /dev/null +++ b/vendor/symfony/console/Completion/CompletionSuggestions.php | |||
@@ -0,0 +1,97 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Console\Completion; | ||
13 | |||
14 | use Symfony\Component\Console\Input\InputOption; | ||
15 | |||
16 | /** | ||
17 | * Stores all completion suggestions for the current input. | ||
18 | * | ||
19 | * @author Wouter de Jong <wouter@wouterj.nl> | ||
20 | */ | ||
21 | final class CompletionSuggestions | ||
22 | { | ||
23 | private array $valueSuggestions = []; | ||
24 | private array $optionSuggestions = []; | ||
25 | |||
26 | /** | ||
27 | * Add a suggested value for an input option or argument. | ||
28 | * | ||
29 | * @return $this | ||
30 | */ | ||
31 | public function suggestValue(string|Suggestion $value): static | ||
32 | { | ||
33 | $this->valueSuggestions[] = !$value instanceof Suggestion ? new Suggestion($value) : $value; | ||
34 | |||
35 | return $this; | ||
36 | } | ||
37 | |||
38 | /** | ||
39 | * Add multiple suggested values at once for an input option or argument. | ||
40 | * | ||
41 | * @param list<string|Suggestion> $values | ||
42 | * | ||
43 | * @return $this | ||
44 | */ | ||
45 | public function suggestValues(array $values): static | ||
46 | { | ||
47 | foreach ($values as $value) { | ||
48 | $this->suggestValue($value); | ||
49 | } | ||
50 | |||
51 | return $this; | ||
52 | } | ||
53 | |||
54 | /** | ||
55 | * Add a suggestion for an input option name. | ||
56 | * | ||
57 | * @return $this | ||
58 | */ | ||
59 | public function suggestOption(InputOption $option): static | ||
60 | { | ||
61 | $this->optionSuggestions[] = $option; | ||
62 | |||
63 | return $this; | ||
64 | } | ||
65 | |||
66 | /** | ||
67 | * Add multiple suggestions for input option names at once. | ||
68 | * | ||
69 | * @param InputOption[] $options | ||
70 | * | ||
71 | * @return $this | ||
72 | */ | ||
73 | public function suggestOptions(array $options): static | ||
74 | { | ||
75 | foreach ($options as $option) { | ||
76 | $this->suggestOption($option); | ||
77 | } | ||
78 | |||
79 | return $this; | ||
80 | } | ||
81 | |||
82 | /** | ||
83 | * @return InputOption[] | ||
84 | */ | ||
85 | public function getOptionSuggestions(): array | ||
86 | { | ||
87 | return $this->optionSuggestions; | ||
88 | } | ||
89 | |||
90 | /** | ||
91 | * @return Suggestion[] | ||
92 | */ | ||
93 | public function getValueSuggestions(): array | ||
94 | { | ||
95 | return $this->valueSuggestions; | ||
96 | } | ||
97 | } | ||