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
Afficher le fichier Open project: webmozart/console Class Usage Examples

Méthodes publiques

Méthode 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 méthode

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

add() public méthode

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 méthode

Removes all commands from the collection.
public clear ( )

contains() public méthode

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

count() public méthode

public count ( )

filterAnonymous() public méthode

public filterAnonymous ( )

filterDefault() public méthode

public filterDefault ( )

filterNonAnonymous() public méthode

public filterNonAnonymous ( )

filterNonDefault() public méthode

public filterNonDefault ( )

get() public méthode

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

getAliases() public méthode

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

getIterator() public méthode

public getIterator ( )

getNames() public méthode

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.
Résultat string[] The sorted command names.

isEmpty() public méthode

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

merge() public méthode

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 méthode

public offsetExists ( $name )

offsetGet() public méthode

public offsetGet ( $name )

offsetSet() public méthode

public offsetSet ( $offset, $command )

offsetUnset() public méthode

public offsetUnset ( $name )

remove() public méthode

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

replace() public méthode

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

toArray() public méthode

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[]
Résultat Command[] The commands indexed by their names.