public function resolve($concrete, $params)
    {
        if ($concrete instanceof \Closure) {
            return $concrete($this, $params);
        }
        $reflector = new \ReflectionClass($concrete);
        // check if class is instantiable
        if (!$reflector->isInstantiable()) {
            throw new \Exception("Class {$concrete} is not instantiable", 500);
        }
        // get class constructor
        $constructor = $reflector->getConstructor();
        if (is_null($constructor)) {
            // get new instance from class
            return $reflector->newInstance();
        }
        // get constructor params
        $parameters = $constructor->getParameters();
        $dependencies = $this->getResolveDependencies($parameters, $params);
        // get new instance with dependencies resolved
        return $reflector->newInstanceArgs($dependencies);
    }
public function resolve($concrete, $params)
    {
        if ($concrete instanceof \Closure) {
            return $concrete($this, $params);
        }
        $reflector = new \ReflectionClass($concrete);
        // check if class is instantiable
        if (!$reflector->isInstantiable()) {
            throw new \Exception("Class {$concrete} is not instantiable", 500);
        }
        // get class constructor
        $constructor = $reflector->getConstructor();
        if (is_null($constructor)) {
            // get new instance from class
            return $reflector->newInstance();
        }
        // get constructor params
        $parameters = $constructor->getParameters();
        $dependencies = $this->getResolveDependencies($parameters, $params);
        // get new instance with dependencies resolved
        return $reflector->newInstanceArgs($dependencies);
    }
public function resolve ( $ concrete , $ params ) { if ( $ concrete instanceof \ Closure ) { return $ concrete ( $ this , $ params ) ; } $ reflector = new \ ReflectionClass ( $ concrete ) ; // check if class is instantiable if ( ! $ reflector -> isInstantiable ( ) ) { throw new \ Exception ( "Class {$concrete} is not instantiable" , 500 ) ; } // get class constructor $ constructor = $ reflector -> getConstructor ( ) ; if ( is_null ( $ constructor ) ) { // get new instance from class return $ reflector -> newInstance ( ) ; } // get constructor params $ parameters = $ constructor -> getParameters ( ) ; $ dependencies = $ this -> getResolveDependencies ( $ parameters , $ params ) ; // get new instance with dependencies resolved return $ reflector -> newInstanceArgs ( $ dependencies ) ; }
Resolve single.

@param $concrete the class.
@param $params constructur args.

@since 3.0.0

@return mixed
Resolve single .