Conditions | 6 |
Paths | 12 |
Total Lines | 15 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 6 |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
31 | 14 | private static function createDefaultRoutes(string $controller): array |
|
32 | { |
||
33 | 14 | $routes = []; |
|
34 | 14 | $reflection = new ReflectionClass($controller); |
|
35 | 14 | foreach (self::METHODS as $methodName => $httpMethod) { |
|
36 | 14 | if ($reflection->hasMethod($methodName)) { |
|
37 | 14 | $pattern = ($methodName === 'list' || $methodName === 'post') ? '' : self::ENTITY_PATTERN; |
|
38 | 14 | $routes[] = Route::methods([$httpMethod], $pattern)->action([$controller, $methodName]); |
|
39 | } |
||
40 | } |
||
41 | 14 | if ($reflection->hasMethod('options')) { |
|
42 | 14 | $routes[] = Route::methods([Method::OPTIONS], '')->action([$controller, 'options']); |
|
43 | } |
||
44 | |||
45 | 14 | return $routes; |
|
46 | } |
||
48 |