protected function mapInputToCommand($command, $input)
    {
        if (is_object($command)) {
            return $command;
        }
        $dependencies = [];
        $class = new ReflectionClass($command);
        foreach ($class->getConstructor()->getParameters() as $parameter) {
            if ( $parameter->getPosition() == 0 && $parameter->isArray() ) {
                if ($input !== []) {
                    $dependencies[] = $input;
                } else {
                    $dependencies[] = $this->getDefaultValueOrFail($parameter);
                }
            } else {
                $name = $parameter->getName();
                if (array_key_exists($name, $input)) {
                    $dependencies[] = $input[$name];
                } else {
                    $dependencies[] = $this->getDefaultValueOrFail($parameter);
                }
            }
        }

        return $class->newInstanceArgs($dependencies);
    }