| Conditions | 9 |
| Paths | 72 |
| Total Lines | 30 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 10.0551 |
| Changes | 0 | ||
| 1 | <?php |
||
| 32 | 22 | public function createUriFromArray(array $server): UriInterface |
|
| 33 | { |
||
| 34 | 22 | $uri = new Uri(''); |
|
| 35 | |||
| 36 | 22 | if (isset($server['REQUEST_SCHEME'])) { |
|
| 37 | $uri = $uri->withScheme($server['REQUEST_SCHEME']); |
||
| 38 | 22 | } elseif (isset($server['HTTPS'])) { |
|
| 39 | $uri = $uri->withScheme('on' === $server['HTTPS'] ? 'https' : 'http'); |
||
| 40 | } |
||
| 41 | |||
| 42 | 22 | if (isset($server['HTTP_HOST'])) { |
|
| 43 | 7 | $uri = $uri->withHost($server['HTTP_HOST']); |
|
| 44 | 15 | } elseif (isset($server['SERVER_NAME'])) { |
|
| 45 | $uri = $uri->withHost($server['SERVER_NAME']); |
||
| 46 | } |
||
| 47 | |||
| 48 | 22 | if (isset($server['SERVER_PORT'])) { |
|
| 49 | $uri = $uri->withPort($server['SERVER_PORT']); |
||
| 50 | } |
||
| 51 | |||
| 52 | 22 | if (isset($server['REQUEST_URI'])) { |
|
| 53 | 7 | $uri = $uri->withPath(current(explode('?', $server['REQUEST_URI']))); |
|
| 54 | } |
||
| 55 | |||
| 56 | 22 | if (isset($server['QUERY_STRING'])) { |
|
| 57 | 7 | $uri = $uri->withQuery($server['QUERY_STRING']); |
|
| 58 | } |
||
| 59 | |||
| 60 | 22 | return $uri; |
|
| 61 | } |
||
| 62 | } |
||
| 63 |