public function get($name)
{
if (isset($this->commands[$name])) {
return $this->commands[$name];
}
if (isset($this->shortNameIndex[$name])) {
return $this->commands[$this->shortNameIndex[$name]];
}
if (isset($this->aliasIndex[$name])) {
return $this->commands[$this->aliasIndex[$name]];
}
throw NoSuchCommandException::forCommandName($name);
}
private static function filterDuplicates(array $names, CommandCollection $commands) { $filteredNames = array(); foreach ($names as $nameToFilter) { // Check all existing names for duplicates foreach ($filteredNames as $filteredName) { // $nameToFilter is a duplicate - skip if ($commands->get($nameToFilter) === $commands->get($filteredName)) { continue 2; } } $filteredNames[] = $nameToFilter; } return $filteredNames; }