| Total Complexity | 2 |
| Total Lines | 33 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | final class NovaApiErrorList |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @var NovaApiError[] errors |
||
| 12 | */ |
||
| 13 | private $errors = []; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * Add error. |
||
| 17 | * |
||
| 18 | * @param string|int $code The code |
||
| 19 | * @param string $message The message |
||
| 20 | * @param array|null $details The details |
||
| 21 | * |
||
| 22 | * @return NovaApiErrorList self |
||
| 23 | */ |
||
| 24 | public function withError($code, string $message, array $details = null): NovaApiErrorList |
||
| 25 | { |
||
| 26 | $clone = clone $this; |
||
| 27 | |||
| 28 | $clone->errors[] = new NovaApiError((string)$code, $message, $details); |
||
| 29 | |||
| 30 | return $clone; |
||
| 31 | } |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Get errors. |
||
| 35 | * |
||
| 36 | * @return NovaApiError[] errors |
||
| 37 | */ |
||
| 38 | public function getErrors(): array |
||
| 41 | } |
||
| 42 | } |
||
| 43 |