W3cubDocs

/Symfony 2.8

Symfony\Component\Console\Input\InputOption

class InputOption

Represents a command line option.

Constants

VALUE_NONE
VALUE_REQUIRED
VALUE_OPTIONAL
VALUE_IS_ARRAY

Methods

__construct(string $name, string|array $shortcut = null, int $mode = null, string $description = '', mixed $default = null)

Constructor.

string getShortcut()

Returns the option shortcut.

string getName()

Returns the option name.

bool acceptValue()

Returns true if the option accepts a value.

bool isValueRequired()

Returns true if the option requires a value.

bool isValueOptional()

Returns true if the option takes an optional value.

bool isArray()

Returns true if the option can take multiple values.

setDefault(mixed $default = null)

Sets the default value.

mixed getDefault()

Returns the default value.

string getDescription()

Returns the description text.

bool equals(InputOption $option)

Checks whether the given option equals this one.

Details

public __construct(string $name, string|array $shortcut = null, int $mode = null, string $description = '', mixed $default = null)

Constructor.

Parameters

string $name The option name
string|array $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts
int $mode The option mode: One of the VALUE_* constants
string $description A description text
mixed $default The default value (must be null for self::VALUEREQUIRED or self::VALUENONE)

Exceptions

InvalidArgumentException If option mode is invalid or incompatible

public string getShortcut()

Returns the option shortcut.

Return Value

string The shortcut

public string getName()

Returns the option name.

Return Value

string The name

public bool acceptValue()

Returns true if the option accepts a value.

Return Value

bool true if value mode is not self::VALUE_NONE, false otherwise

public bool isValueRequired()

Returns true if the option requires a value.

Return Value

bool true if value mode is self::VALUE_REQUIRED, false otherwise

public bool isValueOptional()

Returns true if the option takes an optional value.

Return Value

bool true if value mode is self::VALUE_OPTIONAL, false otherwise

public bool isArray()

Returns true if the option can take multiple values.

Return Value

bool true if mode is self::VALUEISARRAY, false otherwise

public setDefault(mixed $default = null)

Sets the default value.

Parameters

mixed $default The default value

Exceptions

LogicException When incorrect default value is given

public mixed getDefault()

Returns the default value.

Return Value

mixed The default value

public string getDescription()

Returns the description text.

Return Value

string The description text

public bool equals(InputOption $option)

Checks whether the given option equals this one.

Parameters

InputOption $option option to compare

Return Value

bool

© 2004–2016 Fabien Potencier
Licensed under the MIT License.
http://api.symfony.com/2.8/Symfony/Component/Console/Input/InputOption.html