public function command($nameOrCommand, $callable = null)
    {
        if ($nameOrCommand instanceof Command) {
            $command = $nameOrCommand;
        } else {
            if (!is_callable($callable)) {
                throw new \InvalidArgumentException('$callable must be a valid callable with the command\'s code');
            }

            $command = new Command($nameOrCommand);
            $command->setCode($callable);
        }

        $this['console']->add($command);

        return $command;
    }
public function command($nameOrCommand, $callable = null)
    {
        if ($nameOrCommand instanceof Command) {
            $command = $nameOrCommand;
        } else {
            if (!is_callable($callable)) {
                throw new \InvalidArgumentException('$callable must be a valid callable with the command\'s code');
            }

            $command = new Command($nameOrCommand);
            $command->setCode($callable);
        }

        $this['console']->add($command);

        return $command;
    }
public function command ( $ nameOrCommand , $ callable = null ) { if ( $ nameOrCommand instanceof Command ) { $ command = $ nameOrCommand ; } else { if ( ! is_callable ( $ callable ) ) { throw new \ InvalidArgumentException ( '$callable must be a valid callable with the command\'s code' ) ; } $ command = new Command ( $ nameOrCommand ) ; $ command -> setCode ( $ callable ) ; } $ this [ 'console' ] -> add ( $ command ) ; return $ command ; }
Allows you to add a command as Command object or as a command name+callable

@param string|Command $nameOrCommand
@param callable|null $callable Must be a callable if $nameOrCommand is the command's name
@return Command The command instance that you can further configure
@api
Allows you to add a command as Command object or as a command name + callable