\app\framework\Component\Console\InputArgvInput

ArgvInput represents an input coming from the CLI arguments.

Usage:

$input = new ArgvInput();

By default, the $_SERVER['argv'] array is used for the input values.

This can be overridden by explicitly passing the input values in the constructor:

$input = new ArgvInput($_SERVER['argv']);

If you pass it yourself, don't forget that the first element of the array is the name of the running application.

When passing an argument to the constructor, be sure that it respects the same rules as the argv one. It's almost always better to use the StringInput when you want to provide your own input.

Summary

Methods
Properties
Constants
__construct()
bind()
validate()
isInteractive()
setInteractive()
getArguments()
getArgument()
setArgument()
hasArgument()
getOptions()
getOption()
setOption()
hasOption()
escapeToken()
getFirstArgument()
hasParameterOption()
getParameterOption()
__toString()
No public properties found
No constants found
arr()
datetime()
str()
url()
parse()
$definition
$options
$arguments
$interactive
N/A
parseShortOption()
parseShortOptionSet()
parseLongOption()
parseArgument()
addShortOption()
addLongOption()
$tokens
$parsed
N/A

Properties

$definition

$definition : 

Type

$options

$options : 

Type

$arguments

$arguments : 

Type

$interactive

$interactive : 

Type

$tokens

$tokens : 

Type

$parsed

$parsed : 

Type

Methods

validate()

validate() 

Validates the input.

isInteractive()

isInteractive() : boolean

Is this input means interactive?

Returns

boolean

setInteractive()

setInteractive(boolean  $interactive) 

Sets the input interactivity.

Parameters

boolean $interactive

If the input should be interactive

getArguments()

getArguments() : array

Returns all the given arguments merged with the default values.

Returns

array

getArgument()

getArgument(string  $name) : mixed

Returns the argument value for a given argument name.

Parameters

string $name

The argument name

Returns

mixed —

The argument value

setArgument()

setArgument(string  $name, string  $value) 

Sets an argument value by name.

Parameters

string $name

The argument name

string $value

The argument value

hasArgument()

hasArgument(string|integer  $name) : boolean

Returns true if an InputArgument object exists by name or position.

Parameters

string|integer $name

The InputArgument name or position

Returns

boolean —

true if the InputArgument object exists, false otherwise

getOptions()

getOptions() : array

Returns all the given options merged with the default values.

Returns

array

getOption()

getOption(string  $name) : mixed

Returns the option value for a given option name.

Parameters

string $name

The option name

Returns

mixed —

The option value

setOption()

setOption(string  $name, string|boolean  $value) 

Sets an option value by name.

Parameters

string $name

The option name

string|boolean $value

The option value

hasOption()

hasOption(string  $name) : boolean

Returns true if an InputOption object exists by name.

Parameters

string $name

The InputOption name

Returns

boolean —

true if the InputOption object exists, false otherwise

escapeToken()

escapeToken(string  $token) : string

Escapes a token through escapeshellarg if it contains unsafe chars.

Parameters

string $token

Returns

string

getFirstArgument()

getFirstArgument() 

{@inheritdoc}

hasParameterOption()

hasParameterOption(  $values,   $onlyParams = false) 

{@inheritdoc}

Parameters

$values
$onlyParams

getParameterOption()

getParameterOption(  $values,   $default = false,   $onlyParams = false) 

{@inheritdoc}

Parameters

$values
$default
$onlyParams

__toString()

__toString() : string

Returns a stringified representation of the args passed to the command.

Returns

string

datetime()

datetime(string|integer  $time = "now", null|string  $timezone = null) : \app\framework\Component\StdLib\StdObject\DateTimeObject\DateTimeObject

Create an instance of DateTime Standard Object.

Parameters

string|integer $time

A date/time string. List of available formats is explained here http://www.php.net/manual/en/datetime.formats.php

null|string $timezone

Timezone in which you want to set the date. Here is a list of valid timezones: http://php.net/manual/en/timezones.php

Returns

\app\framework\Component\StdLib\StdObject\DateTimeObject\DateTimeObject

parse()

parse() 

Process command line arguments.

parseShortOption()

parseShortOption(string  $token) 

Parses a short option.

Parameters

string $token

The current token

parseShortOptionSet()

parseShortOptionSet(string  $name) 

Parses a short option set.

Parameters

string $name

The current token

Throws

\RuntimeException

When option given doesn't exist

parseLongOption()

parseLongOption(string  $token) 

Parses a long option.

Parameters

string $token

The current token

parseArgument()

parseArgument(string  $token) 

Parses an argument.

Parameters

string $token

The current token

Throws

\RuntimeException

When too many arguments are given

addShortOption()

addShortOption(string  $shortcut, mixed  $value) 

Adds a short option value.

Parameters

string $shortcut

The short option key

mixed $value

The value for the option

Throws

\RuntimeException

When option given doesn't exist

addLongOption()

addLongOption(string  $name, mixed  $value) 

Adds a long option value.

Parameters

string $name

The long option key

mixed $value

The value for the option

Throws

\RuntimeException

When option given doesn't exist