1 | <?php namespace JobApis\Jobs\Client; |
||
9 | class Collection implements Countable |
||
10 | { |
||
11 | /** |
||
12 | * Items |
||
13 | * |
||
14 | * @var array |
||
15 | */ |
||
16 | protected $items = []; |
||
17 | |||
18 | /** |
||
19 | * Errors |
||
20 | * |
||
21 | * @var array |
||
22 | */ |
||
23 | protected $errors = []; |
||
24 | |||
25 | /** |
||
26 | * Add item to collection, at specific key if given |
||
27 | * |
||
28 | * @param mixed $item |
||
29 | * @param integer|string $key Optional |
||
30 | * |
||
31 | * @return Collection |
||
32 | */ |
||
33 | 10 | public function add($item, $key = null) |
|
47 | |||
48 | /** |
||
49 | * Add error to collection |
||
50 | * |
||
51 | * @param string $message |
||
52 | * |
||
53 | * @return Collection |
||
54 | */ |
||
55 | 10 | public function addError($message) |
|
65 | |||
66 | /** |
||
67 | * Get all items from collection |
||
68 | * |
||
69 | * @return array |
||
70 | */ |
||
71 | 2 | public function all() |
|
75 | |||
76 | /** |
||
77 | * Get count of items in collection |
||
78 | * |
||
79 | * @return integer |
||
80 | */ |
||
81 | public function count() |
||
85 | |||
86 | /** |
||
87 | * Delete item from collection at specific key |
||
88 | * |
||
89 | * @param integer|string $key |
||
90 | * |
||
91 | * @return Collection |
||
92 | */ |
||
93 | 4 | public function delete($key) |
|
103 | |||
104 | /** |
||
105 | * Get item from collection at specific key |
||
106 | * |
||
107 | * @param integer|string $key |
||
108 | * |
||
109 | * @return mixed |
||
110 | */ |
||
111 | 6 | public function get($key) |
|
121 | |||
122 | /** |
||
123 | * Get all errors from Collection |
||
124 | * |
||
125 | * @return array |
||
126 | */ |
||
127 | 10 | public function getErrors() |
|
131 | } |
||
132 |