protected static function invokeObject($callback, $matched = null)
    {
        $last = explode('/', $callback);
        $last = end($last);

        $segments = explode('@', $last);

        $class = $segments[0];
        $method = $segments[1];
        $matched = $matched ? $matched : [];

        if (method_exists($class, self::$singleton)) {
            $instance = call_user_func([$class, self::$singleton]);

            return call_user_func_array([$instance, $method], $matched);
        }

        if (class_exists($class)) {
            $instance = new $class;

            return call_user_func_array([$instance, $method], $matched);
        }

        return false;
    }
protected static function invokeObject($callback, $matched = null)
    {
        $last = explode('/', $callback);
        $last = end($last);

        $segments = explode('@', $last);

        $class = $segments[0];
        $method = $segments[1];
        $matched = $matched ? $matched : [];

        if (method_exists($class, self::$singleton)) {
            $instance = call_user_func([$class, self::$singleton]);

            return call_user_func_array([$instance, $method], $matched);
        }

        if (class_exists($class)) {
            $instance = new $class;

            return call_user_func_array([$instance, $method], $matched);
        }

        return false;
    }
protected static function invokeObject ( $ callback , $ matched = null ) { $ last = explode ( '/' , $ callback ) ; $ last = end ( $ last ) ; $ segments = explode ( '@' , $ last ) ; $ class = $ segments [ 0 ] ; $ method = $ segments [ 1 ] ; $ matched = $ matched ? $ matched : [ ] ; if ( method_exists ( $ class , self :: $ singleton ) ) { $ instance = call_user_func ( [ $ class , self :: $ singleton ] ) ; return call_user_func_array ( [ $ instance , $ method ] , $ matched ) ; } if ( class_exists ( $ class ) ) { $ instance = new $ class ; return call_user_func_array ( [ $ instance , $ method ] , $ matched ) ; } return false ; }
Call object and instantiate.

By default it will look for the 'getInstance' method to use singleton
pattern and create a single instance of the class. If it does not
exist it will create a new object.

@see setSingletonName() for change the method name.

@param object $callback
@param array  $matched  → array of matched parameters

@return callable|false
Call object and instantiate .