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 Celema\Router; |
| 6 | |
| 7 | /** @internal */ |
| 8 | final readonly class RouteToken |
| 9 | { |
| 10 | private function __construct( |
| 11 | private RouteTokenType $type, |
| 12 | private string $value = '', |
| 13 | private ?string $name = null, |
| 14 | private ?string $constraint = null, |
| 15 | ) {} |
| 16 | |
| 17 | public static function literal(string $value): self |
| 18 | { |
| 19 | return new self(RouteTokenType::Literal, $value); |
| 20 | } |
| 21 | |
| 22 | public static function parameter(string $name, ?string $constraint = null): self |
| 23 | { |
| 24 | return new self(RouteTokenType::Parameter, name: $name, constraint: $constraint); |
| 25 | } |
| 26 | |
| 27 | public static function remainder(string $name): self |
| 28 | { |
| 29 | return new self(RouteTokenType::Remainder, name: $name); |
| 30 | } |
| 31 | |
| 32 | public function type(): RouteTokenType |
| 33 | { |
| 34 | return $this->type; |
| 35 | } |
| 36 | |
| 37 | public function value(): string |
| 38 | { |
| 39 | return $this->value; |
| 40 | } |
| 41 | |
| 42 | public function name(): ?string |
| 43 | { |
| 44 | return $this->name; |
| 45 | } |
| 46 | |
| 47 | public function constraint(): ?string |
| 48 | { |
| 49 | return $this->constraint; |
| 50 | } |
| 51 | } |