Conditions | 4 |
Paths | 3 |
Total Lines | 26 |
Code Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Tests | 18 |
CRAP Score | 4.016 |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
17 | 2 | public static function match($path, $routes) { |
|
18 | 2 | $controller = null; |
|
|
|||
19 | 2 | $routes = \arc\tree::expand($routes); |
|
20 | 2 | $controller = \arc\tree::dive( |
|
21 | 2 | $routes->cd($path), |
|
22 | 2 | function($node) { |
|
23 | 2 | if ( isset($node->nodeValue) ) { |
|
24 | 2 | return $node; |
|
25 | } |
||
26 | 2 | } |
|
27 | 2 | ); |
|
28 | 2 | if ( $controller ) { |
|
29 | 2 | $remainder = substr( $path, strlen($controller->getPath()) ); |
|
30 | 2 | if ( is_callable($controller->nodeValue) ) { |
|
31 | 2 | $result = call_user_func($controller->nodeValue, $remainder); |
|
32 | 2 | } else { |
|
33 | $result = $controller->nodeValue; |
||
34 | } |
||
35 | return [ |
||
36 | 2 | 'path' => $controller->getPath(), |
|
37 | 2 | 'remainder' => $remainder, |
|
38 | 'result' => $result |
||
39 | 2 | ]; |
|
40 | } |
||
41 | return false; |
||
42 | } |
||
43 | |||
44 | } |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.