Total Complexity | 7 |
Total Lines | 74 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
14 | trait HasErrors |
||
15 | { |
||
16 | /** |
||
17 | * The "errors" member |
||
18 | * |
||
19 | * @var array An array of objects implementing ErrorContract |
||
20 | */ |
||
21 | protected $errors; |
||
22 | |||
23 | /** |
||
24 | * Set the "errors" member |
||
25 | * |
||
26 | * @param array $errors An array of objects implementing ErrorContract |
||
27 | * |
||
28 | * @return static |
||
29 | * @throws JsonApiFakerException |
||
30 | */ |
||
31 | 12 | public function setErrors(array $errors) |
|
42 | } |
||
43 | |||
44 | /** |
||
45 | * Get the "errors" member |
||
46 | * |
||
47 | * An array of ErrorContract objects |
||
48 | * |
||
49 | * @return array|null |
||
50 | */ |
||
51 | 15 | public function getErrors(): ?array |
|
54 | } |
||
55 | |||
56 | /** |
||
57 | * Add a single error to the "errors" member |
||
58 | * |
||
59 | * @param ErrorContract $error |
||
60 | * |
||
61 | * @return static |
||
62 | */ |
||
63 | 6 | public function addError(ErrorContract $error) |
|
64 | { |
||
65 | 6 | $this->addToArray('errors', $error); |
|
|
|||
66 | |||
67 | 6 | return $this; |
|
68 | } |
||
69 | |||
70 | /** |
||
71 | * Fill the "errors" member with fake values |
||
72 | * |
||
73 | * @param integer $count |
||
74 | * |
||
75 | * @return static |
||
76 | * @throws JsonApiFakerException |
||
77 | */ |
||
78 | 3 | public function fakeErrors(int $count = 2) |
|
88 | } |
||
89 | } |
||
90 |