Conditions | 5 |
Paths | 5 |
Total Lines | 26 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 16 |
CRAP Score | 5 |
Changes | 0 |
1 | <?php |
||
27 | 15786 | public static function parse($headers) |
|
28 | { |
||
29 | 15786 | if (is_string($headers)) { |
|
30 | 2115 | $headers = explode("\r\n\r\n", trim($headers)); |
|
31 | |||
32 | 2115 | return explode("\r\n", end($headers)); |
|
33 | } |
||
34 | |||
35 | 15705 | $parsedHeaders = []; |
|
36 | |||
37 | 15705 | foreach ($headers as $name => $value) { |
|
38 | 15642 | $value = HeadersNormalizer::normalizeHeaderValue($value); |
|
39 | |||
40 | 15642 | if (is_int($name)) { |
|
41 | 10774 | if (strpos($value, 'HTTP/') === 0) { |
|
42 | 3078 | $parsedHeaders = [$value]; |
|
43 | 2376 | } else { |
|
44 | 10704 | $parsedHeaders[] = $value; |
|
45 | } |
||
46 | 8304 | } else { |
|
47 | 15586 | $parsedHeaders[] = $name.': '.$value; |
|
48 | } |
||
49 | 12103 | } |
|
50 | |||
51 | 15705 | return $parsedHeaders; |
|
52 | } |
||
53 | } |
||
54 |