Conditions | 4 |
Paths | 2 |
Total Lines | 22 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 4 |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
55 | 13 | private function parse(string $response) |
|
56 | { |
||
57 | 13 | $response = \explode("\r\n\r\n", $response); |
|
58 | |||
59 | 13 | if (\count($response) > 1) { |
|
60 | // We want the last two parts |
||
61 | 9 | $response = \array_slice($response, -2, 2); |
|
62 | |||
63 | 9 | list($headers, $body) = $response; |
|
64 | |||
65 | 9 | foreach (\explode("\r\n", $headers) as $header) { |
|
66 | 9 | $pair = \explode(': ', $header, 2); |
|
67 | |||
68 | 9 | if (isset($pair[1])) { |
|
69 | 9 | $this->headers[$pair[0]] = $pair[1]; |
|
70 | } |
||
71 | } |
||
72 | } else { |
||
73 | 4 | $body = $response[0]; |
|
74 | } |
||
75 | |||
76 | 13 | $this->body = $body; |
|
77 | 13 | } |
|
79 |