| Total Complexity | 4 |
| Total Lines | 37 |
| Duplicated Lines | 0 % |
| Coverage | 36.36% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | final class QueryParams |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * Creates a new Query Params value object. |
||
| 14 | * |
||
| 15 | * @param array<string, string|int> $params |
||
| 16 | */ |
||
| 17 | 20 | private function __construct(private readonly array $params) |
|
| 18 | { |
||
| 19 | // .. |
||
| 20 | 20 | } |
|
| 21 | |||
| 22 | /** |
||
| 23 | * Creates a new Query Params value object |
||
| 24 | */ |
||
| 25 | 20 | public static function create(): self |
|
| 26 | { |
||
| 27 | 20 | return new self([]); |
|
| 28 | } |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Creates a new Query Params value object, with the newly added param, and the existing params. |
||
| 32 | */ |
||
| 33 | public function withParam(string $name, string | int $value): self |
||
| 34 | { |
||
| 35 | return new self([ |
||
| 36 | ...$this->params, |
||
| 37 | $name => $value, |
||
| 38 | ]); |
||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @return array<string, string|int> |
||
| 43 | */ |
||
| 44 | public function toArray(): array |
||
| 47 | } |
||
| 48 | } |
||
| 49 |