Webmozart\Console\Api\Command\CommandCollection::replace PHP Method

replace() public method

Existing commands are replaced.
public replace ( array $commands )
$commands array The commands to set.
    public function replace(array $commands)
    {
        $this->clear();
        $this->merge($commands);
    }

Usage Example

 public function testReplace()
 {
     $this->collection->add($ls = new Command(new CommandConfig('ls')));
     $this->collection->replace(array($cd = new Command(new CommandConfig('cd')), $cat = new Command(new CommandConfig('cat'))));
     $this->assertSame(array('cd' => $cd, 'cat' => $cat), $this->collection->toArray());
 }