private function resolve($key)
    {
        $reflection = new \ReflectionClass($key);

        if (!$reflection->isInstantiable()) {
            return $key;
        }

        $constructor = $reflection->getConstructor();

        if (!$constructor) {
            return $reflection->newInstance();
        }

        $parameters = $constructor->getParameters();

        $parameters_lists = [];

        foreach ($parameters as $parameter) {
            if ($parameter->getClass()) {
                $parameters_lists[] = $this->make($parameter->getClass()->getName());
            } else {
                $parameters_lists[] = $parameter->getDefaultValue();
            }
        }

        if (!empty($this->parameters)) {
            $parameters_lists = $this->parameters;

            $this->parameters = [];
        }

        return $reflection->newInstanceArgs($parameters_lists);
    }
private function resolve($key)
    {
        $reflection = new \ReflectionClass($key);

        if (!$reflection->isInstantiable()) {
            return $key;
        }

        $constructor = $reflection->getConstructor();

        if (!$constructor) {
            return $reflection->newInstance();
        }

        $parameters = $constructor->getParameters();

        $parameters_lists = [];

        foreach ($parameters as $parameter) {
            if ($parameter->getClass()) {
                $parameters_lists[] = $this->make($parameter->getClass()->getName());
            } else {
                $parameters_lists[] = $parameter->getDefaultValue();
            }
        }

        if (!empty($this->parameters)) {
            $parameters_lists = $this->parameters;

            $this->parameters = [];
        }

        return $reflection->newInstanceArgs($parameters_lists);
    }
private function resolve ( $ key ) { $ reflection = new \ ReflectionClass ( $ key ) ; if ( ! $ reflection -> isInstantiable ( ) ) { return $ key ; } $ constructor = $ reflection -> getConstructor ( ) ; if ( ! $ constructor ) { return $ reflection -> newInstance ( ) ; } $ parameters = $ constructor -> getParameters ( ) ; $ parameters_lists = [ ] ; foreach ( $ parameters as $ parameter ) { if ( $ parameter -> getClass ( ) ) { $ parameters_lists [ ] = $ this -> make ( $ parameter -> getClass ( ) -> getName ( ) ) ; } else { $ parameters_lists [ ] = $ parameter -> getDefaultValue ( ) ; } } if ( ! empty ( $ this -> parameters ) ) { $ parameters_lists = $ this -> parameters ; $ this -> parameters = [ ] ; } return $ reflection -> newInstanceArgs ( $ parameters_lists ) ; }
Instantiate a class by its key

@param string $key

@return mixed
@throws
Instantiate a class by its key