Code Duplication    Length = 14-14 lines in 2 locations

src/Mouf/Mvc/Splash/Filters/RedirectToHttpAnnotation.php 1 location

@@ 29-42 (lines=14) @@
26
        $this->port = $values['port'] ?? 80;
27
    }
28
29
    public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next, ContainerInterface $container)
30
    {
31
        $uri = $request->getUri();
32
        $scheme = $uri->getScheme();
33
        if ($scheme === 'https') {
34
            if ($request->getMethod() !== 'GET') {
35
                throw new SplashException('Only GET HTTP methods can be redirected to HTTP');
36
            }
37
            $uri = $uri->withScheme('http')->withPort($this->port);
38
            return new RedirectResponse($uri);
39
        }
40
41
        return $next($request, $response);
42
    }
43
}
44

src/Mouf/Mvc/Splash/Filters/RequireHttpsAnnotation.php 1 location

@@ 38-51 (lines=14) @@
35
        }
36
    }
37
38
    public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next, ContainerInterface $container)
39
    {
40
        $uri = $request->getUri();
41
        $scheme = $uri->getScheme();
42
        if ($scheme === 'http') {
43
            if ($request->getMethod() !== 'GET') {
44
                throw new SplashException('Only GET HTTP methods can be redirected to HTTPS');
45
            }
46
            $uri = $uri->withScheme('https');
47
            return new RedirectResponse($uri);
48
        }
49
50
        return $next($request, $response);
51
    }
52
53
}
54