Conditions | 3 |
Paths | 3 |
Total Lines | 14 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
23 | public function __invoke(ServerRequestInterface $request): string |
||
24 | { |
||
25 | $source = $this->getHeaderLine($request, 'ORIGIN'); |
||
26 | if (null !== $source) { |
||
27 | return parse_url($source, PHP_URL_HOST); |
||
28 | } |
||
29 | |||
30 | $referrer = $this->getHeaderLine($request, 'REFERER'); |
||
31 | if (null === $referrer) { |
||
32 | throw new CsrfHeaderCheckMiddlewareException('Could not find neither the ORIGIN header nor the REFERER header in the HTTP request.'); |
||
33 | } |
||
34 | |||
35 | return parse_url($referrer, PHP_URL_HOST); |
||
36 | } |
||
37 | } |
||
38 |