Documentation

InputOption
in package

Represents a command line option.

Tags
author

Fabien Potencier fabien@symfony.com

Table of Contents

Constants

VALUE_IS_ARRAY  = 8
VALUE_NONE  = 1
VALUE_OPTIONAL  = 4
VALUE_REQUIRED  = 2

Properties

$default  : mixed
$description  : mixed
$mode  : mixed
$name  : mixed
$shortcut  : mixed

Methods

__construct()  : mixed
Constructor.
acceptValue()  : bool
Returns true if the option accepts a value.
equals()  : bool
Checks whether the given option equals this one.
getDefault()  : mixed
Returns the default value.
getDescription()  : string
Returns the description text.
getName()  : string
Returns the option name.
getShortcut()  : string
Returns the option shortcut.
isArray()  : bool
Returns true if the option can take multiple values.
isValueOptional()  : bool
Returns true if the option takes an optional value.
isValueRequired()  : bool
Returns true if the option requires a value.
setDefault()  : mixed
Sets the default value.

Constants

Properties

Methods

__construct()

Constructor.

public __construct(string $name[, string|array<string|int, mixed> $shortcut = null ][, int $mode = null ][, string $description = '' ][, mixed $default = null ]) : mixed
Parameters
$name : string

The option name

$shortcut : string|array<string|int, mixed> = null

The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts

$mode : int = null

The option mode: One of the VALUE_* constants

$description : string = ''

A description text

$default : mixed = null

The default value (must be null for self::VALUE_NONE)

Tags
throws
InvalidArgumentException

If option mode is invalid or incompatible

acceptValue()

Returns true if the option accepts a value.

public acceptValue() : bool
Return values
bool

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

equals()

Checks whether the given option equals this one.

public equals(InputOption $option) : bool
Parameters
$option : InputOption

option to compare

Return values
bool

getDefault()

Returns the default value.

public getDefault() : mixed
Return values
mixed

The default value

getDescription()

Returns the description text.

public getDescription() : string
Return values
string

The description text

getName()

Returns the option name.

public getName() : string
Return values
string

The name

getShortcut()

Returns the option shortcut.

public getShortcut() : string
Return values
string

The shortcut

isArray()

Returns true if the option can take multiple values.

public isArray() : bool
Return values
bool

true if mode is self::VALUE_IS_ARRAY, false otherwise

isValueOptional()

Returns true if the option takes an optional value.

public isValueOptional() : bool
Return values
bool

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

isValueRequired()

Returns true if the option requires a value.

public isValueRequired() : bool
Return values
bool

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

setDefault()

Sets the default value.

public setDefault([mixed $default = null ]) : mixed
Parameters
$default : mixed = null

The default value

Tags
throws
LogicException

When incorrect default value is given


        
On this page

Search results