Psr7Middlewares\Middleware\Www::__invoke PHP Метод

__invoke() публичный Метод

Execute the middleware.
public __invoke ( Psr\Http\Message\ServerRequestInterface $request, Psr\Http\Message\ResponseInterface $response, callable $next ) : Psr\Http\Message\ResponseInterface
$request Psr\Http\Message\ServerRequestInterface
$response Psr\Http\Message\ResponseInterface
$next callable
Результат Psr\Http\Message\ResponseInterface
    public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next)
    {
        $uri = $request->getUri();
        $host = $uri->getHost();
        if ($this->addWww) {
            if ($this->canAddWww($host)) {
                $host = "www.{$host}";
            }
        } elseif (strpos($host, 'www.') === 0) {
            $host = substr($host, 4);
        }
        //redirect
        if ($this->redirectStatus !== false && $uri->getHost() !== $host) {
            return $this->getRedirectResponse($request, $uri->withHost($host), $response);
        }
        return $next($request->withUri($uri->withHost($host)), $response);
    }