| Total Complexity | 12 |
| Total Lines | 64 |
| Duplicated Lines | 0 % |
| Changes | 11 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 5 | trait Helper |
||
| 6 | { |
||
| 7 | protected array $routes = []; |
||
| 8 | protected static Router $instance; |
||
| 9 | protected string $host = ''; |
||
| 10 | private string $prefix = ''; |
||
| 11 | protected ?string $group = null; |
||
| 12 | |||
| 13 | public static function getInstance(): RouterInterface |
||
| 14 | { |
||
| 15 | self::$instance = (!isset(self::$instance)) ? new Router() : self::$instance; |
||
| 16 | return self::$instance; |
||
| 17 | } |
||
| 18 | |||
| 19 | protected static function updateRoute(array $route, $key): RouterInterface |
||
| 20 | { |
||
| 21 | self::getInstance()->getRoutes()[$key] = $route; |
||
| 22 | return self::getInstance(); |
||
| 23 | } |
||
| 24 | |||
| 25 | public static function defineHost(string $host): Router |
||
| 26 | { |
||
| 27 | self::getInstance()->host = $host; |
||
|
|
|||
| 28 | return self::getInstance(); |
||
| 29 | } |
||
| 30 | |||
| 31 | protected function inSave(): array |
||
| 32 | { |
||
| 33 | return end($this->routes); |
||
| 34 | } |
||
| 35 | |||
| 36 | protected function getHost(): string |
||
| 37 | { |
||
| 38 | return $this->host; |
||
| 39 | } |
||
| 40 | |||
| 41 | protected function getRoutes(): array |
||
| 42 | { |
||
| 43 | return $this->routes; |
||
| 44 | } |
||
| 45 | |||
| 46 | protected function setRoutes(array $routes): void |
||
| 47 | { |
||
| 48 | $this->routes = $routes; |
||
| 49 | } |
||
| 50 | |||
| 51 | protected function getGroup(): ?string |
||
| 52 | { |
||
| 53 | return $this->group; |
||
| 54 | } |
||
| 55 | |||
| 56 | protected function setGroup(?string $group): void |
||
| 59 | } |
||
| 60 | |||
| 61 | protected function getPrefix(): ?string |
||
| 62 | { |
||
| 63 | return $this->prefix; |
||
| 64 | } |
||
| 65 | |||
| 66 | protected function setPrefix(string $prefix): void |
||
| 69 | } |
||
| 70 | } |
||
| 71 |