| Total Complexity | 10 |
| Total Lines | 75 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | final class MatchingResult |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @var string[] |
||
| 14 | * @psalm-var array<string,string> |
||
| 15 | */ |
||
| 16 | private array $arguments = []; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @var string[] |
||
| 20 | */ |
||
| 21 | private array $methods = []; |
||
| 22 | |||
| 23 | 18 | private function __construct(private ?Route $route) |
|
| 24 | { |
||
| 25 | 18 | } |
|
| 26 | |||
| 27 | /** |
||
| 28 | * @param string[] $arguments |
||
| 29 | * @psalm-param array<string,string> $arguments |
||
| 30 | */ |
||
| 31 | 11 | public static function fromSuccess(Route $route, array $arguments): self |
|
| 32 | { |
||
| 33 | 11 | $new = new self($route); |
|
| 34 | 11 | $new->arguments = $arguments; |
|
| 35 | 11 | return $new; |
|
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * @param string[] $methods |
||
| 40 | */ |
||
| 41 | 7 | public static function fromFailure(array $methods): self |
|
| 42 | { |
||
| 43 | 7 | $new = new self(null); |
|
| 44 | 7 | $new->methods = $methods; |
|
| 45 | 7 | return $new; |
|
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @psalm-assert-if-true !null $this->route |
||
| 50 | */ |
||
| 51 | 14 | public function isSuccess(): bool |
|
| 52 | { |
||
| 53 | 14 | return $this->route !== null; |
|
| 54 | } |
||
| 55 | |||
| 56 | 16 | public function isMethodFailure(): bool |
|
| 57 | { |
||
| 58 | 16 | return $this->route === null && $this->methods !== Method::ALL; |
|
| 59 | } |
||
| 60 | |||
| 61 | /** |
||
| 62 | * @return string[] |
||
| 63 | * @psalm-return array<string,string> |
||
| 64 | */ |
||
| 65 | 11 | public function arguments(): array |
|
| 66 | { |
||
| 67 | 11 | return $this->arguments; |
|
| 68 | } |
||
| 69 | |||
| 70 | /** |
||
| 71 | * @return string[] |
||
| 72 | */ |
||
| 73 | 4 | public function methods(): array |
|
| 74 | { |
||
| 75 | 4 | return $this->methods; |
|
| 76 | } |
||
| 77 | |||
| 78 | 11 | public function route(): Route |
|
| 85 | } |
||
| 86 | } |
||
| 87 |