Conditions | 3 |
Paths | 3 |
Total Lines | 19 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 3.0067 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
27 | 6 | public static function removeFileExtensionAndKeepQueryString($path) |
|
28 | { |
||
29 | 6 | if (strpos($path, '.') === false) { |
|
30 | return $path; |
||
31 | } |
||
32 | |||
33 | 6 | $pathParts = explode('.', $path); |
|
34 | 6 | $extensionAndQueryString = $pathParts[count($pathParts) - 1]; |
|
35 | 6 | $extensionAndQueryStringParts = explode('?', $extensionAndQueryString, 2); |
|
36 | 6 | unset($pathParts[count($pathParts) - 1]); |
|
37 | |||
38 | 6 | $withoutExtensionAndWithoutQueryString = implode('.', $pathParts); |
|
39 | |||
40 | 6 | if (count($extensionAndQueryStringParts) === 2) { |
|
41 | 3 | return $withoutExtensionAndWithoutQueryString . '?' . $extensionAndQueryStringParts[1]; |
|
42 | } else { |
||
43 | 3 | return $withoutExtensionAndWithoutQueryString; |
|
44 | } |
||
45 | } |
||
46 | } |
||
47 |