trait CommandArguments (View source)

Use this to add arguments and options to the $arguments property.

Properties

protected string $arguments

Methods

$this
arg(string $arg)

Pass argument to executable. Its value will be automatically escaped.

$this
args(string|string[] $args)

Pass methods parameters as arguments to executable. Argument values are automatically escaped.

$this
rawArg(string $arg)

Pass the provided string in its raw (as provided) form as an argument to executable.

static string
escape(string $value)

Escape the provided value, unless it contains only alphanumeric plus a few other basic characters.

$this
option(string $option, string $value = null, string $separator = ' ')

Pass option to executable. Options are prefixed with -- , value can be provided in second parameter.

$this
options(array $options, string $separator = ' ')

Pass multiple options to executable. The associative array contains the key:value pairs that become --key value, for each item in the array.

$this
optionList(string $option, string|array $value = array(), string $separator = ' ')

Pass an option with multiple values to executable. Value can be a string or array.

Details

$this arg(string $arg)

Pass argument to executable. Its value will be automatically escaped.

Parameters

string $arg

Return Value

$this

$this args(string|string[] $args)

Pass methods parameters as arguments to executable. Argument values are automatically escaped.

Parameters

string|string[] $args

Return Value

$this

$this rawArg(string $arg)

Pass the provided string in its raw (as provided) form as an argument to executable.

Parameters

string $arg

Return Value

$this

static string escape(string $value)

Escape the provided value, unless it contains only alphanumeric plus a few other basic characters.

Parameters

string $value

Return Value

string

$this option(string $option, string $value = null, string $separator = ' ')

Pass option to executable. Options are prefixed with -- , value can be provided in second parameter.

Option values are automatically escaped.

Parameters

string $option
string $value
string $separator

Return Value

$this

$this options(array $options, string $separator = ' ')

Pass multiple options to executable. The associative array contains the key:value pairs that become --key value, for each item in the array.

Values are automatically escaped.

Parameters

array $options
string $separator

Return Value

$this

$this optionList(string $option, string|array $value = array(), string $separator = ' ')

Pass an option with multiple values to executable. Value can be a string or array.

Option values are automatically escaped.

Parameters

string $option
string|array $value
string $separator

Return Value

$this