src/Router.php
public function add($path, $middleware = null)
    {
        if (!isset($middleware)) {
            $middleware = $path;
            $path = null;
        }

        if (!empty($path) && !ctype_digit($path) && $path[0] !== '/') {
            trigger_error("Middleware path '$path' doesn't start with a '/'", E_USER_NOTICE);
        }
        
        if (!is_callable($middleware)) {
            throw new \InvalidArgumentException("Middleware should be callable");
        }

        if (!empty($path)) {
            $middleware = $this->wrapMiddleware($path, $middleware);
        }
        
        $this->middlewares[] = $middleware;
        
        return $this;
    }
public function add($path, $middleware = null)
    {
        if (!isset($middleware)) {
            $middleware = $path;
            $path = null;
        }

        if (!empty($path) && !ctype_digit($path) && $path[0] !== '/') {
            trigger_error("Middleware path '$path' doesn't start with a '/'", E_USER_NOTICE);
        }
        
        if (!is_callable($middleware)) {
            throw new \InvalidArgumentException("Middleware should be callable");
        }

        if (!empty($path)) {
            $middleware = $this->wrapMiddleware($path, $middleware);
        }
        
        $this->middlewares[] = $middleware;
        
        return $this;
    }
public function add ( $ path , $ middleware = null ) { if ( ! isset ( $ middleware ) ) { $ middleware = $ path ; $ path = null ; } if ( ! empty ( $ path ) && ! ctype_digit ( $ path ) && $ path [ 0 ] !== '/' ) { trigger_error ( "Middleware path '$path' doesn't start with a '/'" , E_USER_NOTICE ) ; } if ( ! is_callable ( $ middleware ) ) { throw new \ InvalidArgumentException ( "Middleware should be callable" ) ; } if ( ! empty ( $ path ) ) { $ middleware = $ this -> wrapMiddleware ( $ path , $ middleware ) ; } $ this -> middlewares [ ] = $ middleware ; return $ this ; }
Add middleware call to router.

@param string   $path        Middleware is only applied for this path (including subdirectories), may be omitted
@param callable $middleware
@return Router $this
Add middleware call to router .