public add ( |
||
$command | The command to add. |
public function add(Command $command)
{
$name = $command->getName();
$this->commands[$name] = $command;
if ($shortName = $command->getShortName()) {
$this->shortNameIndex[$shortName] = $name;
}
foreach ($command->getAliases() as $alias) {
$this->aliasIndex[$alias] = $name;
}
ksort($this->aliasIndex);
}
public function testIterator() { $this->collection->add($ls = new Command(new CommandConfig('ls'))); $this->collection->add($cd = new Command(new CommandConfig('cd'))); $result = iterator_to_array($this->collection); $this->assertSame(array('ls' => $ls, 'cd' => $cd), $result); }