private static function getCallable($target, array $construct_args)
    {
        if (empty($target)) {
            throw new RuntimeException('No callable provided');
        }

        if (is_string($target)) {
            //is a class "classname::method"
            if (strpos($target, '::') === false) {
                $class = $target;
                $method = '__invoke';
            } else {
                list($class, $method) = explode('::', $target, 2);
            }

            if (!class_exists($class)) {
                throw new RuntimeException("The class {$class} does not exists");
            }

            $fn = new \ReflectionMethod($class, $method);

            if (!$fn->isStatic()) {
                $class = new \ReflectionClass($class);
                $instance = $class->hasMethod('__construct') ? $class->newInstanceArgs($construct_args) : $class->newInstance();
                $target = [$instance, $method];
            }
        }

        //if it's callable as is
        if (is_callable($target)) {
            return $target;
        }

        throw new RuntimeException('Invalid callable provided');
    }
private static function getCallable($target, array $construct_args)
    {
        if (empty($target)) {
            throw new RuntimeException('No callable provided');
        }

        if (is_string($target)) {
            //is a class "classname::method"
            if (strpos($target, '::') === false) {
                $class = $target;
                $method = '__invoke';
            } else {
                list($class, $method) = explode('::', $target, 2);
            }

            if (!class_exists($class)) {
                throw new RuntimeException("The class {$class} does not exists");
            }

            $fn = new \ReflectionMethod($class, $method);

            if (!$fn->isStatic()) {
                $class = new \ReflectionClass($class);
                $instance = $class->hasMethod('__construct') ? $class->newInstanceArgs($construct_args) : $class->newInstance();
                $target = [$instance, $method];
            }
        }

        //if it's callable as is
        if (is_callable($target)) {
            return $target;
        }

        throw new RuntimeException('Invalid callable provided');
    }
private static function getCallable ( $ target , array $ construct_args ) { if ( empty ( $ target ) ) { throw new RuntimeException ( 'No callable provided' ) ; } if ( is_string ( $ target ) ) { //is a class "classname::method" if ( strpos ( $ target , '::' ) === false ) { $ class = $ target ; $ method = '__invoke' ; } else { list ( $ class , $ method ) = explode ( '::' , $ target , 2 ) ; } if ( ! class_exists ( $ class ) ) { throw new RuntimeException ( "The class {$class} does not exists" ) ; } $ fn = new \ ReflectionMethod ( $ class , $ method ) ; if ( ! $ fn -> isStatic ( ) ) { $ class = new \ ReflectionClass ( $ class ) ; $ instance = $ class -> hasMethod ( '__construct' ) ? $ class -> newInstanceArgs ( $ construct_args ) : $ class -> newInstance ( ) ; $ target = [ $ instance , $ method ] ; } } //if it's callable as is if ( is_callable ( $ target ) ) { return $ target ; } throw new RuntimeException ( 'Invalid callable provided' ) ; }
Resolves the target of the route and returns a callable.

@param mixed $target
@param array $construct_args

@throws RuntimeException If the target is not callable

@return callable
Resolves the target of the route and returns a callable .