| Total Complexity | 5 |
| Total Lines | 48 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | class AnonymousController |
||
| 17 | { |
||
| 18 | |||
| 19 | use ControllerDefaultTrait; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @var string|null |
||
| 23 | */ |
||
| 24 | protected ?string $key = null; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * AnonymousController constructor. |
||
| 28 | * |
||
| 29 | * @param mixed ...$args |
||
| 30 | */ |
||
| 31 | public function __construct(mixed ...$args) |
||
| 32 | { |
||
| 33 | call_user_func_array([$this, '__process'], [Router::createRequest(), ...$args]); |
||
| 34 | $this->key = is_string($args[0]) ? $args[0] : 'anonymous@' . __CLASS__; |
||
| 35 | Assistant::passDataToMethod($this, $this->key); |
||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Create an instance of the controller for the application |
||
| 40 | * |
||
| 41 | * @param string $slug The slug of the controller |
||
| 42 | * @param string $class The class name |
||
| 43 | * @param string $uri The uri to be matched |
||
| 44 | * @return array |
||
| 45 | */ |
||
| 46 | public static function __create(string $slug, string $class, string $uri): array |
||
| 47 | { |
||
| 48 | return [ |
||
| 49 | $slug => [ |
||
| 50 | 'controller' => $class, |
||
| 51 | 'uri' => str_ends_with($uri, '/') ? substr($uri, 0, -1) : $uri |
||
| 52 | ] |
||
| 53 | ]; |
||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * Get controller key |
||
| 58 | * |
||
| 59 | * @return string |
||
| 60 | */ |
||
| 61 | public function __routeKeyName(): string |
||
| 64 | } |
||
| 65 | |||
| 66 | } |