protected function mapInputToCommand($command, array $input)
    {
        $dependencies = [];

        $class = new ReflectionClass($command);

        foreach ($class->getConstructor()->getParameters() as $parameter)
        {
            $name = $parameter->getName();

            if (array_key_exists($name, $input))
            {
                $dependencies[] = $input[$name];
            }
            elseif ($parameter->isDefaultValueAvailable())
            {
                $dependencies[] = $parameter->getDefaultValue();
            }
            else
            {
                throw new InvalidArgumentException("Unable to map input to command: {$name}");
            }
        }

        return $class->newInstanceArgs($dependencies);
    }
protected function mapInputToCommand($command, array $input)
    {
        $dependencies = [];

        $class = new ReflectionClass($command);

        foreach ($class->getConstructor()->getParameters() as $parameter)
        {
            $name = $parameter->getName();

            if (array_key_exists($name, $input))
            {
                $dependencies[] = $input[$name];
            }
            elseif ($parameter->isDefaultValueAvailable())
            {
                $dependencies[] = $parameter->getDefaultValue();
            }
            else
            {
                throw new InvalidArgumentException("Unable to map input to command: {$name}");
            }
        }

        return $class->newInstanceArgs($dependencies);
    }
protected function mapInputToCommand ( $ command , array $ input ) { $ dependencies = [ ] ; $ class = new ReflectionClass ( $ command ) ; foreach ( $ class -> getConstructor ( ) -> getParameters ( ) as $ parameter ) { $ name = $ parameter -> getName ( ) ; if ( array_key_exists ( $ name , $ input ) ) { $ dependencies [ ] = $ input [ $ name ] ; } elseif ( $ parameter -> isDefaultValueAvailable ( ) ) { $ dependencies [ ] = $ parameter -> getDefaultValue ( ) ; } else { throw new InvalidArgumentException ( "Unable to map input to command: {$name}" ) ; } } return $ class -> newInstanceArgs ( $ dependencies ) ; }
Map an array of input to a command's properties.

@param  string $command
@param  array $input
@throws InvalidArgumentException
@author Taylor Otwell

@return mixed
Map an array of input to a command s properties .