public function execute()
    {
        if (is_string($this->callback)) {
            // Will call the controller here
            $parts = explode('::', $this->callback);
            $className = $parts[0];
            $classMethod = $parts[1];

            if (! class_exists($className)) {
                throw new RouterException("The callback class declared in your middleware is not found: '{$className}'");
            }

            $class = new $className();

            if (! $class instanceof BaseMiddleware) {
                throw new RouterException("The class in your middleware route doesn't extend the BaseMiddleware: '{$className}'"); // @codeCoverageIgnore
            }

            if (! method_exists($class, $classMethod)) {
                throw new RouterException("The class in your middleware route doesn't have the method you provided: '{$className}' method: {$classMethod}");
            }

            // Call the method. Catch return
            $result = call_user_func(array($class, $classMethod));

        } elseif (is_callable($this->callback)) {
            $result = call_user_func($this->callback);

        } else {
            throw new RouterException("Middleware callback is not a class or callable!"); // @codeCoverageIgnore
        }

        // See if we got a boolean back.
        if ($result === false && $this->position === 'before') {
            // We should stop!
            return false;
        }
        return true;
    }
public function execute()
    {
        if (is_string($this->callback)) {
            // Will call the controller here
            $parts = explode('::', $this->callback);
            $className = $parts[0];
            $classMethod = $parts[1];

            if (! class_exists($className)) {
                throw new RouterException("The callback class declared in your middleware is not found: '{$className}'");
            }

            $class = new $className();

            if (! $class instanceof BaseMiddleware) {
                throw new RouterException("The class in your middleware route doesn't extend the BaseMiddleware: '{$className}'"); // @codeCoverageIgnore
            }

            if (! method_exists($class, $classMethod)) {
                throw new RouterException("The class in your middleware route doesn't have the method you provided: '{$className}' method: {$classMethod}");
            }

            // Call the method. Catch return
            $result = call_user_func(array($class, $classMethod));

        } elseif (is_callable($this->callback)) {
            $result = call_user_func($this->callback);

        } else {
            throw new RouterException("Middleware callback is not a class or callable!"); // @codeCoverageIgnore
        }

        // See if we got a boolean back.
        if ($result === false && $this->position === 'before') {
            // We should stop!
            return false;
        }
        return true;
    }
public function execute ( ) { if ( is_string ( $ this -> callback ) ) { // Will call the controller here $ parts = explode ( '::' , $ this -> callback ) ; $ className = $ parts [ 0 ] ; $ classMethod = $ parts [ 1 ] ; if ( ! class_exists ( $ className ) ) { throw new RouterException ( "The callback class declared in your middleware is not found: '{$className}'" ) ; } $ class = new $ className ( ) ; if ( ! $ class instanceof BaseMiddleware ) { throw new RouterException ( "The class in your middleware route doesn't extend the BaseMiddleware: '{$className}'" ) ; // @codeCoverageIgnore } if ( ! method_exists ( $ class , $ classMethod ) ) { throw new RouterException ( "The class in your middleware route doesn't have the method you provided: '{$className}' method: {$classMethod}" ) ; } // Call the method. Catch return $ result = call_user_func ( array ( $ class , $ classMethod ) ) ; } elseif ( is_callable ( $ this -> callback ) ) { $ result = call_user_func ( $ this -> callback ) ; } else { throw new RouterException ( "Middleware callback is not a class or callable!" ) ; // @codeCoverageIgnore } // See if we got a boolean back. if ( $ result === false && $ this -> position === 'before' ) { // We should stop! return false ; } return true ; }
Execute Callback in middleware, capture the output of it.

@return bool can we continue?

@throws RouterException
Execute Callback in middleware capture the output of it .