PHP Class Webmozart\Console\Api\Command\CommandCollection

Since: 1.0
Author: Bernhard Schussek ([email protected])
Inheritance: implements ArrayAcces\ArrayAccess, implements IteratorAggregat\IteratorAggregate, implements Countabl\Countable
Exibir arquivo Open project: webmozart/console Class Usage Examples

Public Methods

Method Description
__construct ( array $commands = [] ) Creates a new command collection.
add ( Command $command ) Adds a command to the collection.
clear ( ) Removes all commands from the collection.
contains ( string $name ) : boolean Returns whether the collection contains a command with the given name.
count ( )
filterAnonymous ( )
filterDefault ( )
filterNonAnonymous ( )
filterNonDefault ( )
get ( string $name ) : Command Returns a command by its name.
getAliases ( ) : string[] Returns the aliases of all commands in the collection.
getIterator ( )
getNames ( boolean $includeAliases = false ) : string[] Returns the names of all commands in the collection.
isEmpty ( ) : boolean Returns whether the collection is empty.
merge ( array $commands ) Adds multiple commands to the collection.
offsetExists ( $name )
offsetGet ( $name )
offsetSet ( $offset, $command )
offsetUnset ( $name )
remove ( string $name ) Removes the command with the given name from the collection.
replace ( array $commands ) Sets the commands in the collection.
toArray ( ) : Command[] Returns the contents of the collection as array.

Method Details

__construct() public method

Creates a new command collection.
public __construct ( array $commands = [] )
$commands array The commands to initially add to the collection.

add() public method

If a command exists with the same name in the collection, that command is overwritten.
public add ( Command $command )
$command Command The command to add.

clear() public method

Removes all commands from the collection.
public clear ( )

contains() public method

Returns whether the collection contains a command with the given name.
public contains ( string $name ) : boolean
$name string The name of the command.
return boolean Returns `true` if the collection contains a command with that name and `false` otherwise.

count() public method

public count ( )

filterAnonymous() public method

public filterAnonymous ( )

filterDefault() public method

public filterDefault ( )

filterNonAnonymous() public method

public filterNonAnonymous ( )

filterNonDefault() public method

public filterNonDefault ( )

get() public method

Returns a command by its name.
public get ( string $name ) : Command
$name string The name of the command.
return Command The command.

getAliases() public method

The aliases are sorted alphabetically in ascending order.
public getAliases ( ) : string[]
return string[] The command names indexed and sorted by their aliases.

getIterator() public method

public getIterator ( )

getNames() public method

The names are sorted alphabetically in ascending order. If you set $includeAliases to true, the alias names are included in the result.
public getNames ( boolean $includeAliases = false ) : string[]
$includeAliases boolean Whether to include alias names in the result.
return string[] The sorted command names.

isEmpty() public method

Returns whether the collection is empty.
public isEmpty ( ) : boolean
return boolean Returns `true` if the collection is empty and `false` otherwise.

merge() public method

Existing commands are preserved. Commands with the same names as the passed commands are overwritten.
public merge ( array $commands )
$commands array The commands to add.

offsetExists() public method

public offsetExists ( $name )

offsetGet() public method

public offsetGet ( $name )

offsetSet() public method

public offsetSet ( $offset, $command )

offsetUnset() public method

public offsetUnset ( $name )

remove() public method

If no such command can be found, the method does nothing.
public remove ( string $name )
$name string The name of the command.

replace() public method

Existing commands are replaced.
public replace ( array $commands )
$commands array The commands to set.

toArray() public method

The commands in the collection are returned indexed by their names. The result is sorted in the order in which the commands were added to the collection.
public toArray ( ) : Command[]
return Command[] The commands indexed by their names.