| Total Complexity | 5 |
| Total Lines | 31 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | final class RestGroupFactory |
||
| 13 | { |
||
| 14 | private const ENTITY_PATTERN = '{id:\d+}'; |
||
| 15 | |||
| 16 | private const METHODS = [ |
||
| 17 | 'get' => Method::GET, |
||
| 18 | 'list' => Method::GET, |
||
| 19 | 'post' => Method::POST, |
||
| 20 | 'put' => Method::PUT, |
||
| 21 | 'delete' => Method::DELETE, |
||
| 22 | 'patch' => Method::PATCH, |
||
| 23 | 'options' => Method::OPTIONS, |
||
| 24 | ]; |
||
| 25 | |||
| 26 | public static function create(string $prefix, string $controller): Group |
||
| 27 | { |
||
| 28 | return Group::create($prefix)->routes(...self::createDefaultRoutes($controller)); |
||
| 29 | } |
||
| 30 | |||
| 31 | private static function createDefaultRoutes(string $controller): array |
||
| 43 | } |
||
| 44 | } |
||
| 45 |