Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
Middleware
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 1
 handle
n/a
0 / 0
1
n/a
0 / 0
 redirect
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
<?php
declare(strict_types=1);
namespace Eywa\Http\Middleware {
    use Closure;
    use Exception;
    use Eywa\Exception\Kedavra;
    use Eywa\Http\Request\ServerRequest;
    use Eywa\Http\Response\RedirectResponse;
    use Eywa\Http\Response\Response;
    abstract class Middleware
    {
        /**
         *
         * Check the request
         *
         * @param ServerRequest $request
         * @param Closure $next
         *
         * @return Response
         *
         * @throws Kedavra
         * @throws Exception
         *
         */
        abstract public function handle(ServerRequest $request, Closure $next): Response;
        /**
         *
         * Redirect to the url
         *
         * @param string $url
         * @param int $status
         *
         * @return Response
         *
         * @throws Kedavra
         */
        public function redirect(string $url, int $status = 301): Response
        {
            return (new RedirectResponse($url, $status))->send();
        }
    }
}