Output
2 years ago
CompletionInput.php
2 years ago
CompletionSuggestions.php
2 years ago
Suggestion.php
2 years ago
CompletionSuggestions.php
89 lines
| 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 | namespace IAWP_SCOPED\Symfony\Component\Console\Completion; |
| 12 | |
| 13 | use IAWP_SCOPED\Symfony\Component\Console\Input\InputOption; |
| 14 | /** |
| 15 | * Stores all completion suggestions for the current input. |
| 16 | * |
| 17 | * @author Wouter de Jong <wouter@wouterj.nl> |
| 18 | * @internal |
| 19 | */ |
| 20 | final class CompletionSuggestions |
| 21 | { |
| 22 | private $valueSuggestions = []; |
| 23 | private $optionSuggestions = []; |
| 24 | /** |
| 25 | * Add a suggested value for an input option or argument. |
| 26 | * |
| 27 | * @param string|Suggestion $value |
| 28 | * |
| 29 | * @return $this |
| 30 | */ |
| 31 | public function suggestValue($value) : self |
| 32 | { |
| 33 | $this->valueSuggestions[] = !$value instanceof Suggestion ? new Suggestion($value) : $value; |
| 34 | return $this; |
| 35 | } |
| 36 | /** |
| 37 | * Add multiple suggested values at once for an input option or argument. |
| 38 | * |
| 39 | * @param list<string|Suggestion> $values |
| 40 | * |
| 41 | * @return $this |
| 42 | */ |
| 43 | public function suggestValues(array $values) : self |
| 44 | { |
| 45 | foreach ($values as $value) { |
| 46 | $this->suggestValue($value); |
| 47 | } |
| 48 | return $this; |
| 49 | } |
| 50 | /** |
| 51 | * Add a suggestion for an input option name. |
| 52 | * |
| 53 | * @return $this |
| 54 | */ |
| 55 | public function suggestOption(InputOption $option) : self |
| 56 | { |
| 57 | $this->optionSuggestions[] = $option; |
| 58 | return $this; |
| 59 | } |
| 60 | /** |
| 61 | * Add multiple suggestions for input option names at once. |
| 62 | * |
| 63 | * @param InputOption[] $options |
| 64 | * |
| 65 | * @return $this |
| 66 | */ |
| 67 | public function suggestOptions(array $options) : self |
| 68 | { |
| 69 | foreach ($options as $option) { |
| 70 | $this->suggestOption($option); |
| 71 | } |
| 72 | return $this; |
| 73 | } |
| 74 | /** |
| 75 | * @return InputOption[] |
| 76 | */ |
| 77 | public function getOptionSuggestions() : array |
| 78 | { |
| 79 | return $this->optionSuggestions; |
| 80 | } |
| 81 | /** |
| 82 | * @return Suggestion[] |
| 83 | */ |
| 84 | public function getValueSuggestions() : array |
| 85 | { |
| 86 | return $this->valueSuggestions; |
| 87 | } |
| 88 | } |
| 89 |