1 | <?php |
||
2 | |||
3 | namespace Bdf\Prime\Collection; |
||
4 | |||
5 | use Countable; |
||
6 | use ArrayAccess; |
||
7 | use Traversable; |
||
8 | |||
9 | /** |
||
10 | * CollectionInterface |
||
11 | * |
||
12 | * @template E |
||
13 | * |
||
14 | * @extends ArrayAccess<array-key, E> |
||
15 | * @extends Traversable<array-key, E> |
||
16 | */ |
||
17 | interface CollectionInterface extends Countable, ArrayAccess, Traversable |
||
18 | { |
||
19 | public const GROUPBY = 0; |
||
20 | public const GROUPBY_COMBINE = 1; |
||
21 | public const GROUPBY_PRESERVE = 2; |
||
22 | public const GROUPBY_CUSTOM = 3; |
||
23 | |||
24 | /** |
||
25 | * Replace all items |
||
26 | * |
||
27 | * @param E[] $items |
||
28 | * |
||
29 | * @return $this |
||
30 | */ |
||
31 | public function pushAll(array $items); |
||
32 | |||
33 | /** |
||
34 | * Push an item onto the end of the collection. |
||
35 | * |
||
36 | * @param E $item |
||
37 | * |
||
38 | * @return $this |
||
39 | */ |
||
40 | public function push($item); |
||
41 | |||
42 | /** |
||
43 | * Put an item in the collection by key. |
||
44 | * |
||
45 | * @param array-key|null $key |
||
0 ignored issues
–
show
Documentation
Bug
introduced
by
![]() |
|||
46 | * @param E $item |
||
47 | * |
||
48 | * @return $this |
||
49 | */ |
||
50 | public function put($key, $item); |
||
51 | |||
52 | /** |
||
53 | * Get all of the items in the collection. |
||
54 | * |
||
55 | * @return E[] |
||
56 | */ |
||
57 | public function all(); |
||
58 | |||
59 | /** |
||
60 | * Get an item from the collection by key. |
||
61 | * |
||
62 | * @param array-key $key |
||
0 ignored issues
–
show
|
|||
63 | * @param E|null $default |
||
64 | * |
||
65 | * @return E|null |
||
66 | */ |
||
67 | public function get($key, $default = null); |
||
68 | |||
69 | /** |
||
70 | * Determine if an item exists in the collection by key. |
||
71 | * |
||
72 | * @param array-key $key |
||
0 ignored issues
–
show
|
|||
73 | * @return bool |
||
74 | */ |
||
75 | public function has($key); |
||
76 | |||
77 | /** |
||
78 | * Remove an item from the collection by key. |
||
79 | * |
||
80 | * @param array-key $key |
||
0 ignored issues
–
show
|
|||
81 | * |
||
82 | * @return $this |
||
83 | */ |
||
84 | public function remove($key); |
||
85 | |||
86 | /** |
||
87 | * Clear the collection |
||
88 | * |
||
89 | * @return $this |
||
90 | */ |
||
91 | public function clear(); |
||
92 | |||
93 | /** |
||
94 | * Get the keys of the collection items. |
||
95 | * |
||
96 | * @return list<array-key> |
||
0 ignored issues
–
show
The type
Bdf\Prime\Collection\list was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
97 | */ |
||
98 | public function keys(); |
||
99 | |||
100 | /** |
||
101 | * Determine if collection is empty |
||
102 | * |
||
103 | * @return boolean |
||
104 | */ |
||
105 | public function isEmpty(); |
||
106 | |||
107 | /** |
||
108 | * Runs a callback to every items |
||
109 | * |
||
110 | * @param callable(E):R $callback The function to run |
||
111 | * @return self<R> The new collection |
||
112 | * |
||
113 | * @template R |
||
114 | */ |
||
115 | public function map($callback); |
||
116 | |||
117 | /** |
||
118 | * Filter every entites with a callback |
||
119 | * |
||
120 | * @param callable(E):bool $callback The function to run |
||
121 | * @return static The new filtered collection |
||
122 | */ |
||
123 | public function filter($callback = null); |
||
124 | |||
125 | /** |
||
126 | * Group an associative array by a field or using a callback. |
||
127 | * |
||
128 | * The mode values: |
||
129 | * 0. rebuild on group key, |
||
130 | * 1. combine if group key exist, |
||
131 | * 2. combine and preservee key |
||
132 | * 3. custom injection in the new collection. The callback has to be a callable |
||
133 | * |
||
134 | * @param callable(mixed,array-key,array)|string $groupBy |
||
135 | * @param int $mode |
||
136 | * |
||
137 | * @return self |
||
138 | * |
||
139 | * @throws \LogicException if the mode custom is set and the callback is not a callable |
||
140 | */ |
||
141 | public function groupBy($groupBy, $mode = self::GROUPBY); |
||
142 | |||
143 | /** |
||
144 | * Determine if an item exists in the collection. |
||
145 | * |
||
146 | * @param mixed $element |
||
147 | * |
||
148 | * @return bool |
||
149 | */ |
||
150 | public function contains($element); |
||
151 | |||
152 | /** |
||
153 | * Search the collection for a given value and return the corresponding key if successful. |
||
154 | * |
||
155 | * @param mixed $value |
||
156 | * @param bool $strict |
||
157 | * |
||
158 | * @return array-key|false |
||
0 ignored issues
–
show
|
|||
159 | */ |
||
160 | public function indexOf($value, $strict = false); |
||
161 | |||
162 | /** |
||
163 | * Merge the collection with the given items. |
||
164 | * |
||
165 | * @param E[]|CollectionInterface<E> $items |
||
166 | * @return self<E> |
||
167 | */ |
||
168 | public function merge($items); |
||
169 | |||
170 | /** |
||
171 | * Sort through each item with a callback. |
||
172 | * |
||
173 | * @param callable|null $callback |
||
174 | * @return self<E> |
||
175 | */ |
||
176 | public function sort(callable $callback = null); |
||
177 | |||
178 | /** |
||
179 | * Export entity's properties in array |
||
180 | * |
||
181 | * @return E[] |
||
182 | */ |
||
183 | public function toArray(); |
||
184 | } |
||
185 |