Conditions | 2 |
Paths | 2 |
Total Lines | 18 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php |
||
16 | public static function createFrom(string $method, string $url, string $response, int $headerSize) : self { |
||
17 | |||
18 | $result = new self(); |
||
19 | |||
20 | $header = substr($response, 0, $headerSize); |
||
21 | $body = substr($response, $headerSize); |
||
22 | |||
23 | $body_json = json_decode($body, true); |
||
24 | |||
25 | $result->request = $method . ' ' . $url; |
||
26 | |||
27 | $result->header = array_map(function($line) { |
||
28 | return trim($line); |
||
29 | }, explode("\n", $header)); |
||
30 | |||
31 | $result->body = $body_json === null ? $body : $body_json; |
||
32 | |||
33 | return $result; |
||
34 | } |
||
57 | } |