| Conditions | 3 |
| Paths | 2 |
| Total Lines | 30 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 24 | protected function sendRequest( |
||
| 25 | RequestInterface $request, |
||
| 26 | int $maxRedirectJumps = 5 |
||
| 27 | ): ResponseInterface { |
||
| 28 | $responses = []; |
||
| 29 | |||
| 30 | jump: |
||
| 31 | |||
| 32 | $response = $this->httpClient->sendRequest($request); |
||
| 33 | |||
| 34 | $redirectCodes = [307]; |
||
| 35 | |||
| 36 | if (in_array($response->getStatusCode(), $redirectCodes)) { |
||
| 37 | $responses[] = $response; |
||
| 38 | |||
| 39 | if (count($responses) >= $maxRedirectJumps) { |
||
| 40 | throw new TooManyJumpsException($request, $responses); |
||
| 41 | } |
||
| 42 | |||
| 43 | $uri = current($response->getHeader('Location')); |
||
| 44 | |||
| 45 | /** |
||
| 46 | * @psalm-suppress UnusedVariable |
||
| 47 | */ |
||
| 48 | $request = $request->withUri(new Uri($uri)); |
||
| 49 | |||
| 50 | goto jump; |
||
| 51 | } |
||
| 52 | |||
| 53 | return $response; |
||
| 54 | } |
||
| 56 |