public function buildCommand($command, $callable, array $options = [])
    {
        if (is_string($callable)) {
            $callable = function ($message) use ($callable) {
                return $callable;
            };
        } elseif (is_array($callable) && ! is_callable($callable)) {
            $callable = function ($message) use ($callable) {
                return $callable[array_rand($callable)];
            };
        }

        if (! is_callable($callable)) {
            throw new \Exception('The callable parameter must be a string, array or callable.');
        }

        $options = $this->resolveCommandOptions($options);

        $commandInstance = new Command(
            $this, $command, $callable,
            $options['description'], $options['usage'], $options['aliases']);

        return [$commandInstance, $options];
    }
public function buildCommand($command, $callable, array $options = [])
    {
        if (is_string($callable)) {
            $callable = function ($message) use ($callable) {
                return $callable;
            };
        } elseif (is_array($callable) && ! is_callable($callable)) {
            $callable = function ($message) use ($callable) {
                return $callable[array_rand($callable)];
            };
        }

        if (! is_callable($callable)) {
            throw new \Exception('The callable parameter must be a string, array or callable.');
        }

        $options = $this->resolveCommandOptions($options);

        $commandInstance = new Command(
            $this, $command, $callable,
            $options['description'], $options['usage'], $options['aliases']);

        return [$commandInstance, $options];
    }
public function buildCommand ( $ command , $ callable , array $ options = [ ] ) { if ( is_string ( $ callable ) ) { $ callable = function ( $ message ) use ( $ callable ) { return $ callable ; } ; } elseif ( is_array ( $ callable ) && ! is_callable ( $ callable ) ) { $ callable = function ( $ message ) use ( $ callable ) { return $ callable [ array_rand ( $ callable ) ] ; } ; } if ( ! is_callable ( $ callable ) ) { throw new \ Exception ( 'The callable parameter must be a string, array or callable.' ) ; } $ options = $ this -> resolveCommandOptions ( $ options ) ; $ commandInstance = new Command ( $ this , $ command , $ callable , $ options [ 'description' ] , $ options [ 'usage' ] , $ options [ 'aliases' ] ) ; return [ $ commandInstance , $ options ] ; }
Builds a command and returns it.

@param string           $command  The command name.
@param \Callable|string $callable The function called when the command is executed.
@param array            $options  An array of options.

@return array[Command, array] The command instance and options.
Builds a command and returns it .