Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
100.00% |
14 / 14 |
|
100.00% |
4 / 4 |
|
100.00% |
4 / 4 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
1 / 1 |
| Issue | |
100.00% |
14 / 14 |
|
100.00% |
4 / 4 |
|
100.00% |
4 / 4 |
|
100.00% |
4 / 4 |
4 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| withPrefix | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| toArray | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| jsonSerialize | |
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\Sire; |
| 6 | |
| 7 | use JsonSerializable; |
| 8 | use Override; |
| 9 | |
| 10 | /** @api */ |
| 11 | final readonly class Issue implements JsonSerializable |
| 12 | { |
| 13 | /** |
| 14 | * @param list<string|int> $path |
| 15 | * @param array<string, mixed> $params |
| 16 | */ |
| 17 | public function __construct( |
| 18 | public array $path, |
| 19 | public string $code, |
| 20 | public string $message, |
| 21 | public array $params = [], |
| 22 | ) {} |
| 23 | |
| 24 | /** @param list<string|int> $prefix */ |
| 25 | public function withPrefix(array $prefix): self |
| 26 | { |
| 27 | return new self( |
| 28 | [...$prefix, ...$this->path], |
| 29 | $this->code, |
| 30 | $this->message, |
| 31 | $this->params, |
| 32 | ); |
| 33 | } |
| 34 | |
| 35 | /** @return array{path: list<string|int>, code: string, message: string, params: array<string, mixed>} */ |
| 36 | public function toArray(): array |
| 37 | { |
| 38 | return [ |
| 39 | 'path' => $this->path, |
| 40 | 'code' => $this->code, |
| 41 | 'message' => $this->message, |
| 42 | 'params' => $this->params, |
| 43 | ]; |
| 44 | } |
| 45 | |
| 46 | /** @return array{path: list<string|int>, code: string, message: string, params: array<string, mixed>} */ |
| 47 | #[Override] |
| 48 | public function jsonSerialize(): array |
| 49 | { |
| 50 | return $this->toArray(); |
| 51 | } |
| 52 | } |