| Total Complexity | 10 | 
| Total Lines | 60 | 
| Duplicated Lines | 0 % | 
| Changes | 0 | ||
| 1 | <?php | ||
| 8 | trait TraitErrors | ||
| 9 | { | ||
| 10 | protected $errors = []; | ||
| 11 | |||
| 12 | /** | ||
| 13 | * @param string $code | ||
| 14 | * @param $error | ||
| 15 | */ | ||
| 16 | public function addError($code, $error) | ||
| 22 | } | ||
| 23 | |||
| 24 | /** | ||
| 25 | * @param null|string $code | ||
| 26 | * @return bool | ||
| 27 | */ | ||
| 28 | public function hasErrors($code = null): bool | ||
| 31 | } | ||
| 32 | |||
| 33 | /** | ||
| 34 | * @param null|string $code | ||
| 35 | * @return array | ||
| 36 | */ | ||
| 37 | public function getErrors($code = null): array | ||
| 38 |     { | ||
| 39 |         if ($code !== null) { | ||
| 40 | return $this->errors[$code] ?? []; | ||
| 41 | } | ||
| 42 | return $this->errors; | ||
| 43 | } | ||
| 44 | |||
| 45 | /** | ||
| 46 | * @return array | ||
| 47 | */ | ||
| 48 | public function getFirstErrors(): array | ||
| 57 | } | ||
| 58 | |||
| 59 | /** | ||
| 60 | * @param null|string $code | ||
| 61 | */ | ||
| 62 | public function resetErrors($code = null) | ||
| 68 | } | ||
| 69 | } | ||
| 71 |