4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Console\Input;
14 use Symfony\Component\Console\Exception\InvalidArgumentException;
15 use Symfony\Component\Console\Exception\RuntimeException;
18 * InputInterface is the interface implemented by all input classes.
20 * @author Fabien Potencier <fabien@symfony.com>
22 interface InputInterface
25 * Returns the first argument from the raw parameters (not parsed).
27 * @return string|null The value of the first argument or null otherwise
29 public function getFirstArgument();
32 * Returns true if the raw parameters (not parsed) contain a value.
34 * This method is to be used to introspect the input parameters
35 * before they have been validated. It must be used carefully.
36 * Does not necessarily return the correct result for short options
37 * when multiple flags are combined in the same option.
39 * @param string|array $values The values to look for in the raw parameters (can be an array)
40 * @param bool $onlyParams Only check real parameters, skip those following an end of options (--) signal
42 * @return bool true if the value is contained in the raw parameters
44 public function hasParameterOption($values, $onlyParams = false);
47 * Returns the value of a raw option (not parsed).
49 * This method is to be used to introspect the input parameters
50 * before they have been validated. It must be used carefully.
51 * Does not necessarily return the correct result for short options
52 * when multiple flags are combined in the same option.
54 * @param string|array $values The value(s) to look for in the raw parameters (can be an array)
55 * @param mixed $default The default value to return if no result is found
56 * @param bool $onlyParams Only check real parameters, skip those following an end of options (--) signal
58 * @return mixed The option value
60 public function getParameterOption($values, $default = false, $onlyParams = false);
63 * Binds the current Input instance with the given arguments and options.
65 * @throws RuntimeException
67 public function bind(InputDefinition $definition);
70 * Validates the input.
72 * @throws RuntimeException When not enough arguments are given
74 public function validate();
77 * Returns all the given arguments merged with the default values.
81 public function getArguments();
84 * Returns the argument value for a given argument name.
86 * @param string $name The argument name
88 * @return string|string[]|null The argument value
90 * @throws InvalidArgumentException When argument given doesn't exist
92 public function getArgument($name);
95 * Sets an argument value by name.
97 * @param string $name The argument name
98 * @param string|string[]|null $value The argument value
100 * @throws InvalidArgumentException When argument given doesn't exist
102 public function setArgument($name, $value);
105 * Returns true if an InputArgument object exists by name or position.
107 * @param string|int $name The InputArgument name or position
109 * @return bool true if the InputArgument object exists, false otherwise
111 public function hasArgument($name);
114 * Returns all the given options merged with the default values.
118 public function getOptions();
121 * Returns the option value for a given option name.
123 * @param string $name The option name
125 * @return string|string[]|bool|null The option value
127 * @throws InvalidArgumentException When option given doesn't exist
129 public function getOption($name);
132 * Sets an option value by name.
134 * @param string $name The option name
135 * @param string|string[]|bool|null $value The option value
137 * @throws InvalidArgumentException When option given doesn't exist
139 public function setOption($name, $value);
142 * Returns true if an InputOption object exists by name.
144 * @param string $name The InputOption name
146 * @return bool true if the InputOption object exists, false otherwise
148 public function hasOption($name);
151 * Is this input means interactive?
155 public function isInteractive();
158 * Sets the input interactivity.
160 * @param bool $interactive If the input should be interactive
162 public function setInteractive($interactive);