Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 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 $valueSuggestions = [];
24
    private $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
}