| Conditions | 4 |
| Paths | 4 |
| Total Lines | 22 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php declare(strict_types=1); |
||
| 20 | function server_request_protocol_version(?array $serverParams = null): string |
||
| 21 | { |
||
| 22 | 59 | $serverParams ??= $_SERVER; |
|
| 23 | |||
| 24 | 59 | if (!isset($serverParams['SERVER_PROTOCOL'])) { |
|
| 25 | 47 | return '1.1'; |
|
| 26 | } |
||
| 27 | |||
| 28 | // "HTTP" "/" 1*digit "." 1*digit |
||
| 29 | 12 | sscanf($serverParams['SERVER_PROTOCOL'], 'HTTP/%d.%d', $major, $minor); |
|
|
|
|||
| 30 | |||
| 31 | // e.g.: HTTP/1.1 |
||
| 32 | 12 | if (isset($minor)) { |
|
| 33 | 6 | return sprintf('%d.%d', $major, $minor); |
|
| 34 | } |
||
| 35 | |||
| 36 | // e.g.: HTTP/2 |
||
| 37 | 6 | if (isset($major)) { |
|
| 38 | 2 | return sprintf('%d', $major); |
|
| 39 | } |
||
| 40 | |||
| 41 | 4 | return '1.1'; |
|
| 42 | } |
||
| 43 |