Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
100.00% |
8 / 8 |
|
100.00% |
8 / 8 |
|
100.00% |
8 / 8 |
|
100.00% |
8 / 8 |
CRAP | |
100.00% |
1 / 1 |
| RouteToken | |
100.00% |
8 / 8 |
|
100.00% |
8 / 8 |
|
100.00% |
8 / 8 |
|
100.00% |
8 / 8 |
8 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| literal | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| parameter | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| remainder | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| type | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| value | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| name | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| constraint | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Celemas\Router; |
| 6 | |
| 7 | /** @internal */ |
| 8 | final readonly class RouteToken |
| 9 | { |
| 10 | public const string LITERAL = 'literal'; |
| 11 | public const string PARAMETER = 'parameter'; |
| 12 | public const string REMAINDER = 'remainder'; |
| 13 | |
| 14 | private function __construct( |
| 15 | private string $type, |
| 16 | private string $value = '', |
| 17 | private ?string $name = null, |
| 18 | private ?string $constraint = null, |
| 19 | ) {} |
| 20 | |
| 21 | public static function literal(string $value): self |
| 22 | { |
| 23 | return new self(self::LITERAL, $value); |
| 24 | } |
| 25 | |
| 26 | public static function parameter(string $name, ?string $constraint = null): self |
| 27 | { |
| 28 | return new self(self::PARAMETER, name: $name, constraint: $constraint); |
| 29 | } |
| 30 | |
| 31 | public static function remainder(string $name): self |
| 32 | { |
| 33 | return new self(self::REMAINDER, name: $name); |
| 34 | } |
| 35 | |
| 36 | public function type(): string |
| 37 | { |
| 38 | return $this->type; |
| 39 | } |
| 40 | |
| 41 | public function value(): string |
| 42 | { |
| 43 | return $this->value; |
| 44 | } |
| 45 | |
| 46 | public function name(): ?string |
| 47 | { |
| 48 | return $this->name; |
| 49 | } |
| 50 | |
| 51 | public function constraint(): ?string |
| 52 | { |
| 53 | return $this->constraint; |
| 54 | } |
| 55 | } |