| Total Complexity | 5 |
| Total Lines | 45 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | class State |
||
| 9 | { |
||
| 10 | private string $prefix; |
||
| 11 | |||
| 12 | private array $middleware; |
||
| 13 | |||
| 14 | private ?string $domain; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Constructor |
||
| 18 | * |
||
| 19 | * @param string $prefix |
||
| 20 | * @param array $middleware |
||
| 21 | * @param string|null $domain |
||
| 22 | */ |
||
| 23 | public function __construct(string $prefix = '', array $middleware = [], ?string $domain = null) |
||
| 24 | { |
||
| 25 | $this->prefix = $prefix; |
||
| 26 | $this->middleware = $middleware; |
||
| 27 | $this->domain = $domain; |
||
| 28 | } |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Append new attributes to the existing ones |
||
| 32 | */ |
||
| 33 | public function append(array $attributes): void |
||
| 34 | { |
||
| 35 | $this->domain = $attributes[Attributes::DOMAIN] ?? null; |
||
| 36 | $this->prefix .= $attributes[Attributes::PREFIX] ?? ''; |
||
| 37 | $this->middleware = array_merge($this->middleware, $attributes[Attributes::MIDDLEWARE] ?? []); |
||
| 38 | } |
||
| 39 | |||
| 40 | public function getPrefix(): string |
||
| 41 | { |
||
| 42 | return $this->prefix; |
||
| 43 | } |
||
| 44 | |||
| 45 | public function getMiddleware(): array |
||
| 46 | { |
||
| 47 | return $this->middleware; |
||
| 48 | } |
||
| 49 | |||
| 50 | public function getDomain(): ?string |
||
| 53 | } |
||
| 54 | } |
||
| 55 |