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