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

get() public method

Returns a command by its name.
public get ( string $name ) : Command
$name string The name of the command.
return Command The command.
    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);
    }

Usage Example

コード例 #1
0
 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;
 }
All Usage Examples Of Webmozart\Console\Api\Command\CommandCollection::get