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