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