Webmozart\Console\Api\Command\CommandCollection::clear PHP Méthode

clear() public méthode

Removes all commands from the collection.
public clear ( )
    public function clear()
    {
        $this->commands = array();
        $this->shortNameIndex = array();
        $this->aliasIndex = array();
    }

Usage Example

 public function testCount()
 {
     $this->assertCount(0, $this->collection);
     $this->collection->add(new Command(new CommandConfig('ls')));
     $this->assertCount(1, $this->collection);
     $this->collection->add(new Command(new CommandConfig('cd')));
     $this->assertCount(2, $this->collection);
     $this->collection->remove('ls');
     $this->assertCount(1, $this->collection);
     $this->collection->clear();
     $this->assertCount(0, $this->collection);
 }