Conditions | 5 |
Paths | 12 |
Total Lines | 21 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 5.0187 |
Changes | 0 |
1 | <?php |
||
12 | 3 | public function normalizePath($path) |
|
13 | { |
||
14 | // Fix for wildcard protocol URLs, as parse_url (until PHP 5.4.7) requires the protocol to be set |
||
15 | // @see http://www.php.net/manual/en/function.parse-url.php |
||
16 | 3 | if ('//' === substr($path, 0, 2)) { |
|
17 | 1 | $path = 'http:' . $path; |
|
18 | } |
||
19 | |||
20 | 3 | $pathInfos = parse_url($path); |
|
21 | |||
22 | 3 | if (isset($pathInfos['path'])) { |
|
23 | 3 | $path = $pathInfos['path']; |
|
24 | 3 | if (isset($pathInfos['query'])) { |
|
25 | $path .= '?' . $pathInfos['query']; |
||
26 | } |
||
27 | } |
||
28 | |||
29 | 3 | if (strpos($path, '/') === 0) { |
|
30 | 1 | $path = substr($path, 1); |
|
31 | } |
||
32 | 3 | return $path; |
|
33 | } |
||
34 | } |