| Conditions | 4 |
| Paths | 3 |
| Total Lines | 25 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 14 |
| CRAP Score | 4.0312 |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | 4 | public static function match($path, $routes) { |
|
| 18 | 4 | $routes = \arc\tree::expand($routes); |
|
| 19 | 4 | $controller = \arc\tree::dive( |
|
| 20 | 4 | $routes->cd($path), |
|
| 21 | function($node) { |
||
| 22 | 4 | if ( isset($node->nodeValue) ) { |
|
| 23 | 4 | return $node; |
|
| 24 | } |
||
| 25 | 4 | } |
|
| 26 | ); |
||
| 27 | 4 | if ( $controller ) { |
|
| 28 | 4 | $remainder = substr( $path, strlen($controller->getPath()) ); |
|
| 29 | 4 | if ( is_callable($controller->nodeValue) ) { |
|
| 30 | 4 | $result = call_user_func($controller->nodeValue, $remainder); |
|
| 31 | } else { |
||
| 32 | $result = $controller->nodeValue; |
||
| 33 | } |
||
| 34 | return [ |
||
| 35 | 4 | 'path' => $controller->getPath(), |
|
| 36 | 4 | 'remainder' => $remainder, |
|
| 37 | 4 | 'result' => $result |
|
| 38 | ]; |
||
| 39 | } |
||
| 40 | return false; |
||
| 41 | } |
||
| 42 | |||
| 43 | } |