PHP Класс Webmozart\Console\Api\Args\Format\ArgsFormatBuilder

Use the methods in this class to dynamically build {@link ArgsFormat} instances. When you are done configuring the builder, call {@link getFormat()} to build an immutable {@link ArgsFormat}. For convenience, you can call {@link ArgsFormat::build()} to create a new builder and use its fluent API to configure and build a format: php $format = ArgsFormat::build() ->addCommandName(new CommandName('server')) ->addCommandOption(new CommandOption('add', 'a')) ->addArgument(new Argument('host')) ->addOption(new Option('port', 'p')) ->getFormat(); You can optionally pass a base format to inherit from. The arguments of the base format are prepended to the arguments of the built format. The options of the base format are added to the built options: php $baseFormat = ArgsFormat::build() ->addOption(new Option('verbose', 'v')) ->getFormat(); $format = ArgsFormat::build($baseFormat) ... ->getFormat(); Read {@link ArgsFormat} for a more detailed description of args formats.
См. также: ArgsFormat
С версии: 1.0
Автор: Bernhard Schussek ([email protected])
Показать файл Открыть проект Примеры использования класса

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

Метод Описание
__construct ( ArgsFormat $baseFormat = null ) Creates a new builder.
addArgument ( Argument $argument ) : static Adds an argument at the end of the argument list.
addArguments ( array $arguments ) : static Adds arguments at the end of the argument list.
addCommandName ( CommandName $commandName ) : static Adds a command name to the built format.
addCommandNames ( array $commandNames ) : static Adds command names to the built format.
addCommandOption ( CommandOption $commandOption ) : static Adds a command option to the builder.
addCommandOptions ( array $commandOptions ) : static Adds command options to the builder.
addOption ( Option $option ) : static Adds an option at the end of the options list.
addOptions ( array $options ) : static Adds options at the end of the options list.
getArgument ( string | integer $name, boolean $includeBase = true ) : Argument Returns an argument by its name or position.
getArguments ( boolean $includeBase = true ) : Argument[] Returns all arguments added to the builder.
getBaseFormat ( ) : ArgsFormat Returns the base format.
getCommandNames ( boolean $includeBase = true ) : CommandName[] Returns all command names added to the builder.
getCommandOption ( string $name, boolean $includeBase = true ) : CommandOption Returns a command option by its long or short name.
getCommandOptions ( boolean $includeBase = true ) : CommandOption[] Returns all command options added to the builder.
getFormat ( ) : ArgsFormat Builds a format with the arguments and options added to the builder.
getOption ( string $name, boolean $includeBase = true ) : Option Returns an option by its long or short name.
getOptions ( boolean $includeBase = true ) : Option[] Returns all options added to the builder.
hasArgument ( string | integer $name, boolean $includeBase = true ) : boolean Returns whether the builder contains a specific argument.
hasArguments ( boolean $includeBase = true ) : boolean Returns whether the builder contains any argument.
hasCommandNames ( boolean $includeBase = true ) : boolean Returns whether the builder contains any command names.
hasCommandOption ( string $name, boolean $includeBase = true ) : boolean Returns whether the builder contains a specific command option.
hasCommandOptions ( boolean $includeBase = true ) : boolean Returns whether the builder contains any command options.
hasMultiValuedArgument ( boolean $includeBase = true ) : boolean Returns whether the builder contains a multi-valued argument.
hasOption ( string $name, boolean $includeBase = true ) : boolean Returns whether the builder contains a specific option.
hasOptionalArgument ( boolean $includeBase = true ) : boolean Returns whether the builder contains an optional argument.
hasOptions ( boolean $includeBase = true ) : boolean Returns whether the builder contains any option.
hasRequiredArgument ( boolean $includeBase = true ) : boolean Returns whether the builder contains a required argument.
setArguments ( array $arguments ) : static Sets the arguments of the built format.
setCommandNames ( array $commandNames ) : static Sets the command names of the built format.
setCommandOptions ( array $commandOptions ) : static Sets the command options of the built format.
setOptions ( array $options ) : static Sets the options of the built format.

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

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

You can optionally pass a base format. The built format inherits all the arguments and options from the base format.
public __construct ( ArgsFormat $baseFormat = null )
$baseFormat ArgsFormat The base format.

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

The existing arguments stored in the builder are preserved. You cannot add arguments after adding a multi-valued argument. If you do so, this method throws an exception. Adding required arguments after optional arguments is not supported. Also in this case an exception is thrown.
public addArgument ( Argument $argument ) : static
$argument Argument The argument to add.
Результат static The current instance.

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

The existing arguments stored in the builder are preserved.
См. также: addArgument()
public addArguments ( array $arguments ) : static
$arguments array The arguments to add.
Результат static The current instance.

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

Adds a command name to the built format.
public addCommandName ( CommandName $commandName ) : static
$commandName CommandName The command name to add.
Результат static The current instance.

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

Adds command names to the built format.
public addCommandNames ( array $commandNames ) : static
$commandNames array The command names to add.
Результат static The current instance.

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

The existing command options stored in the builder are preserved.
См. также: addCommandOptions()
public addCommandOption ( CommandOption $commandOption ) : static
$commandOption CommandOption The command option to add.
Результат static The current instance.

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

The existing command options stored in the builder are preserved.
См. также: addCommandOption()
public addCommandOptions ( array $commandOptions ) : static
$commandOptions array The command options to add.
Результат static The current instance.

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

The existing options stored in the builder are preserved.
См. также: addOptions()
public addOption ( Option $option ) : static
$option Option The option to add.
Результат static The current instance.

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

The existing options stored in the builder are preserved.
См. также: addOption()
public addOptions ( array $options ) : static
$options array The options to add.
Результат static The current instance.

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

You can either pass the name of the argument or the 0-based position of the argument.
public getArgument ( string | integer $name, boolean $includeBase = true ) : Argument
$name string | integer The argument name or its 0-based position in the argument list.
$includeBase boolean Whether to include arguments in the base format in the search.
Результат Argument The argument.

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

Returns all arguments added to the builder.
public getArguments ( boolean $includeBase = true ) : Argument[]
$includeBase boolean Whether to include arguments of the base format in the result.
Результат Argument[] The arguments.

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

Returns the base format.
public getBaseFormat ( ) : ArgsFormat
Результат ArgsFormat The base format.

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

Returns all command names added to the builder.
public getCommandNames ( boolean $includeBase = true ) : CommandName[]
$includeBase boolean Whether to include command names of the base format in the result.
Результат CommandName[] The command names.

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

Returns a command option by its long or short name.
public getCommandOption ( string $name, boolean $includeBase = true ) : CommandOption
$name string The long or short option name.
$includeBase boolean Whether to include command options in the base format in the search.
Результат CommandOption The command option.

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

Returns all command options added to the builder.
public getCommandOptions ( boolean $includeBase = true ) : CommandOption[]
$includeBase boolean Whether to include command options of the base format in the result.
Результат CommandOption[] The command options.

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

Builds a format with the arguments and options added to the builder.
public getFormat ( ) : ArgsFormat
Результат ArgsFormat The built format.

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

Returns an option by its long or short name.
public getOption ( string $name, boolean $includeBase = true ) : Option
$name string The long or short option name.
$includeBase boolean Whether to include options in the base format in the search.
Результат Option The option.

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

Returns all options added to the builder.
public getOptions ( boolean $includeBase = true ) : Option[]
$includeBase boolean Whether to include options of the base format in the result.
Результат Option[] The options.

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

You can either pass the name of the argument or the 0-based position of the argument.
public hasArgument ( string | integer $name, boolean $includeBase = true ) : boolean
$name string | integer The argument name or its 0-based position in the argument list.
$includeBase boolean Whether to include arguments in the base format in the search.
Результат boolean Returns `true` if the argument with the given name or position could be found and `false` otherwise.

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

Returns whether the builder contains any argument.
public hasArguments ( boolean $includeBase = true ) : boolean
$includeBase boolean Whether to include arguments in the base format in the search.
Результат boolean Returns `true` if the builder contains any argument and `false` otherwise.

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

Returns whether the builder contains any command names.
public hasCommandNames ( boolean $includeBase = true ) : boolean
$includeBase boolean Whether to consider command names of the base format.
Результат boolean Returns `true` if the builder contains any command names and `false` otherwise.

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

You can either pass the long or the short name of the command option.
public hasCommandOption ( string $name, boolean $includeBase = true ) : boolean
$name string The long or short option name.
$includeBase boolean Whether to include command options in the base format in the search.
Результат boolean Returns `true` if the command option with the given name could be found and `false` otherwise.

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

Returns whether the builder contains any command options.
public hasCommandOptions ( boolean $includeBase = true ) : boolean
$includeBase boolean Whether to include command options in the base format in the search.
Результат boolean Returns `true` if the builder contains command options and `false` otherwise.

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

Returns whether the builder contains a multi-valued argument.
public hasMultiValuedArgument ( boolean $includeBase = true ) : boolean
$includeBase boolean Whether to include arguments in the base format in the search.
Результат boolean Returns `true` if the builder contains a multi-valued argument and `false` otherwise.

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

You can either pass the long or the short name of the option.
public hasOption ( string $name, boolean $includeBase = true ) : boolean
$name string The long or short option name.
$includeBase boolean Whether to include options in the base format in the search.
Результат boolean Returns `true` if the option with the given name could be found and `false` otherwise.

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

Returns whether the builder contains an optional argument.
public hasOptionalArgument ( boolean $includeBase = true ) : boolean
$includeBase boolean Whether to include arguments in the base format in the search.
Результат boolean Returns `true` if the builder contains an optional argument and `false` otherwise.

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

Returns whether the builder contains any option.
public hasOptions ( boolean $includeBase = true ) : boolean
$includeBase boolean Whether to include options in the base format in the search.
Результат boolean Returns `true` if the builder contains any option and `false` otherwise.

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

Returns whether the builder contains a required argument.
public hasRequiredArgument ( boolean $includeBase = true ) : boolean
$includeBase boolean Whether to include arguments in the base format in the search.
Результат boolean Returns `true` if the builder contains a required argument and `false` otherwise.

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

Any existing arguments are removed when this method is called.
См. также: addArgument()
public setArguments ( array $arguments ) : static
$arguments array The arguments of the built format.
Результат static The current instance.

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

Sets the command names of the built format.
public setCommandNames ( array $commandNames ) : static
$commandNames array The command names.
Результат static The current instance.

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

Any existing command options are removed when this method is called.
См. также: addCommandOption()
public setCommandOptions ( array $commandOptions ) : static
$commandOptions array The command options of the built format.
Результат static The current instance.

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

Any existing options are removed when this method is called.
См. также: addOption()
public setOptions ( array $options ) : static
$options array The options of the built format.
Результат static The current instance.