1 | <?php |
||
15 | abstract class EntityCollection implements \Countable, \Iterator |
||
16 | { |
||
17 | /** @var array */ |
||
18 | private $entities; |
||
19 | /** @var bool */ |
||
20 | protected $allowEntitiesChildren; |
||
21 | |||
22 | /** |
||
23 | * @return string |
||
24 | */ |
||
25 | abstract public static function entityClass(): string; |
||
26 | |||
27 | /** |
||
28 | * Collection constructor. |
||
29 | * @param array $entities |
||
30 | * @param bool $allowEntitiesChildren |
||
31 | * @throws \Exception |
||
32 | */ |
||
33 | 44 | public function __construct(array $entities, bool $allowEntitiesChildren = false) |
|
45 | |||
46 | /** |
||
47 | * @param $entity |
||
48 | * @throws \Exception |
||
49 | */ |
||
50 | 2 | public function add($entity) |
|
58 | |||
59 | /** |
||
60 | * @param $key |
||
61 | * @param $entity |
||
62 | * @throws \Exception |
||
63 | */ |
||
64 | 42 | public function set($key, $entity) |
|
72 | |||
73 | /** |
||
74 | * @param $entity |
||
75 | * @return bool |
||
76 | */ |
||
77 | 42 | public function isValid($entity): bool |
|
88 | |||
89 | /** |
||
90 | * @return array |
||
91 | */ |
||
92 | 3 | public function keys(): array |
|
96 | |||
97 | /** |
||
98 | * @return array |
||
99 | */ |
||
100 | 3 | public function values(): array |
|
104 | |||
105 | /** |
||
106 | * @return mixed |
||
107 | */ |
||
108 | 3 | public function first() |
|
112 | |||
113 | /** |
||
114 | * @return mixed |
||
115 | */ |
||
116 | 3 | public function last() |
|
120 | |||
121 | /** |
||
122 | * @return array |
||
123 | */ |
||
124 | 3 | public function toArray(): array |
|
128 | |||
129 | /** |
||
130 | * @return mixed |
||
131 | */ |
||
132 | 11 | public function current() |
|
136 | |||
137 | /** |
||
138 | * @return mixed |
||
139 | */ |
||
140 | 13 | public function next() |
|
144 | |||
145 | /** |
||
146 | * @return mixed |
||
147 | */ |
||
148 | 9 | public function key() |
|
152 | |||
153 | /** |
||
154 | * @return bool |
||
155 | */ |
||
156 | 4 | public function valid(): bool |
|
160 | |||
161 | 4 | public function rewind() |
|
165 | |||
166 | /** |
||
167 | * @return int |
||
168 | */ |
||
169 | 5 | public function count(): int |
|
173 | |||
174 | /** |
||
175 | * @return \Exception |
||
176 | */ |
||
177 | 1 | public static function customEmptyException(): \Exception |
|
181 | |||
182 | /** |
||
183 | * @return \Exception |
||
184 | */ |
||
185 | 1 | public static function customInvalidEntityException(): \Exception |
|
189 | } |
||
190 |