PHP Класс kahlan\cli\CommandLine

Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$_defaults array Defaults options values
$_options array Arguments attributes
$_values array Arguments values.

Открытые методы

Метод Описание
__construct ( array $options = [] ) The Constructor.
add ( string $name, mixed $value ) : array Adds a value to a specific option (or set if it's not an array).
cast ( string $value, string $type, boolean $array = false ) : array Casts a value according to the option attributes.
exists ( string $name ) : boolean Checks if an option has been setted.
get ( string $name = null ) : array Gets the value of a specific option.
option ( string $name = null, array $config = [], $value = null ) : array Gets/Sets/Overrides an option's attributes.
options ( ) : array Returns all options attributes.
parse ( array $argv, boolean $override = true ) : array Parses a command line argv.
set ( string $name, mixed $value ) : array Sets the value of a specific option.

Защищенные методы

Метод Описание
_get ( string $name ) : array Helper for get().
_parse ( string $arg ) : array Helper for parse().
_splitOptionName ( string $name ) : array Helper to split option name

Описание методов

__construct() публичный Метод

The Constructor.
public __construct ( array $options = [] )
$options array An array of option's attributes where keys are option's names and values are an array of attributes.

_get() защищенный Метод

Helper for get().
protected _get ( string $name ) : array
$name string The name of the option.
Результат array The casted value.

_parse() защищенный Метод

Helper for parse().
protected _parse ( string $arg ) : array
$arg string A string argument.
Результат array The parsed argument

_splitOptionName() защищенный Метод

Helper to split option name
protected _splitOptionName ( string $name ) : array
$name string The option name.
Результат array

add() публичный Метод

Adds a value to a specific option (or set if it's not an array).
public add ( string $name, mixed $value ) : array
$name string The name of the option.
$value mixed The value of the option to set.
Результат array The setted value.

cast() публичный Метод

Casts a value according to the option attributes.
public cast ( string $value, string $type, boolean $array = false ) : array
$value string The value to cast.
$type string The type of the value.
$array boolean If `true`, the argument value is considered to be an array.
Результат array The casted value.

exists() публичный Метод

Checks if an option has been setted.
public exists ( string $name ) : boolean
$name string The name of the option.
Результат boolean

get() публичный Метод

Gets the value of a specific option.
public get ( string $name = null ) : array
$name string The name of the option.
Результат array The value.

option() публичный Метод

Gets/Sets/Overrides an option's attributes.
public option ( string $name = null, array $config = [], $value = null ) : array
$name string The name of the option.
$config array The option attributes to set.
Результат array

options() публичный Метод

Returns all options attributes.
public options ( ) : array
Результат array

parse() публичный Метод

Parses a command line argv.
public parse ( array $argv, boolean $override = true ) : array
$argv array An argv data.
$override boolean If set to `false` it doesn't override already setted data.
Результат array The parsed attributes

set() публичный Метод

Sets the value of a specific option.
public set ( string $name, mixed $value ) : array
$name string The name of the option.
$value mixed The value of the option to set.
Результат array The setted value.

Описание свойств

$_defaults защищенное свойство

Defaults options values
protected array $_defaults
Результат array

$_options защищенное свойство

Arguments attributes
protected array $_options
Результат array

$_values защищенное свойство

Arguments values.
protected array $_values
Результат array