| Conditions | 2 |
| Paths | 2 |
| Total Lines | 20 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 15 |
| CRAP Score | 2 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 21 | 81 | public static function configure(Closure $fn): void |
|
| 22 | { |
||
| 23 | 81 | $routes = new Routes(); |
|
| 24 | 81 | $bindings = new Bindings(); |
|
| 25 | 81 | $handlers = new Handlers(); |
|
| 26 | |||
| 27 | 81 | $params = array_map(static fn ($param) => match ((string)$param->getType()) { |
|
| 28 | 81 | Routes::class => $routes, |
|
| 29 | 81 | Bindings::class => $bindings, |
|
| 30 | 81 | Handlers::class => $handlers, |
|
| 31 | 81 | default => null, |
|
| 32 | 81 | }, (new ReflectionFunction($fn))->getParameters()); |
|
| 33 | |||
| 34 | 81 | $fn(...$params); |
|
| 35 | |||
| 36 | try { |
||
| 37 | 80 | echo self::findRoute($routes) |
|
| 38 | 80 | ->run($bindings); |
|
| 39 | 10 | } catch (Exception $exception) { |
|
| 40 | 10 | echo (string) self::findHandler($handlers, $exception)($exception); |
|
| 41 | } |
||
| 66 |