| 1 | <?php |
||
| 14 | final class ResponseTranslator |
||
| 15 | { |
||
| 16 | private $transformed; |
||
| 17 | |||
| 18 | 4 | public function __construct() |
|
| 25 | |||
| 26 | 2 | public function translate(ResponseInterface $response): Response |
|
| 27 | { |
||
| 28 | 2 | if ($this->transformed->contains($response)) { |
|
| 29 | return $this->transformed->get($response); |
||
| 30 | } |
||
| 31 | |||
| 32 | 2 | $sfResponse = (new Response( |
|
| 33 | 2 | (string) $response->body(), |
|
| 34 | 2 | $response->statusCode()->value(), |
|
| 35 | 2 | $this->translateHeaders($response->headers()) |
|
| 36 | )) |
||
| 37 | 2 | ->setProtocolVersion((string) $response->protocolVersion()); |
|
| 38 | 2 | $this->transformed = $this->transformed->put( |
|
| 39 | $response, |
||
| 40 | $sfResponse |
||
| 41 | ); |
||
| 42 | |||
| 43 | 2 | return $sfResponse; |
|
| 44 | } |
||
| 45 | |||
| 46 | 2 | private function translateHeaders(HeadersInterface $headers): array |
|
| 65 | } |
||
| 66 |