Conditions | 2 |
Paths | 2 |
Total Lines | 22 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
23 | public function create(string $destinationUrl) |
||
24 | { |
||
25 | // create a PSR7 request based on the current browser request. |
||
26 | $request = ServerRequestFactory::fromGlobals(); |
||
27 | $currentHost = $request->getUri()->getHost(); |
||
28 | |||
29 | $requestedUrl = new Uri($destinationUrl); |
||
30 | $requestedUrl = $requestedUrl->withPath(''); |
||
31 | |||
32 | /** @var ServerRequest $request */ |
||
33 | $request = $request->withUri($requestedUrl); |
||
34 | |||
35 | if ($currentHost === $request->getUri()->getHost()) { // @codeCoverageIgnore |
||
36 | throw new \Exception('Cannot make a request to the same host as we are'); // @codeCoverageIgnore |
||
37 | } |
||
38 | |||
39 | // do the clean up before passing through the request |
||
40 | $request = $request->withoutHeader('ww-target-url'); |
||
41 | $request = $request->withoutHeader('ww-token'); |
||
42 | |||
43 | return $request; |
||
44 | } |
||
45 | } |
||
46 |