1 | <?php |
||
22 | abstract class AbstractCollection |
||
23 | implements \ArrayAccess, \IteratorAggregate, \Countable |
||
|
|||
24 | { |
||
25 | /** |
||
26 | * Returns the size of the collection |
||
27 | * |
||
28 | * @return int The size of the collection |
||
29 | */ |
||
30 | abstract public function size() : int; |
||
31 | |||
32 | /** |
||
33 | * Returns how many elements are in the Collection |
||
34 | * |
||
35 | * @return int The number of elements in the Collection |
||
36 | */ |
||
37 | 4 | public function count() |
|
41 | |||
42 | /** |
||
43 | * Checks if the Collection is empty |
||
44 | * |
||
45 | * @return boolean True if the element is empty |
||
46 | */ |
||
47 | 2 | public function empty() |
|
51 | |||
52 | /** |
||
53 | * Basic implementation of contains |
||
54 | * |
||
55 | * Should be overridden by datatype-specific implementations for |
||
56 | * speed improvements |
||
57 | * |
||
58 | * @param ValueType $searchFor The key to search for |
||
59 | * @return boolean |
||
60 | */ |
||
61 | 1 | public function contains($searchFor) : bool |
|
62 | { |
||
63 | 1 | foreach ($this as $item) |
|
64 | { |
||
65 | 1 | if ($item === $searchFor) |
|
66 | { |
||
67 | 1 | return true; |
|
68 | } |
||
69 | } |
||
70 | |||
71 | 1 | return false; |
|
72 | } |
||
73 | |||
74 | public function map(callable $cb) |
||
81 | } |
||
82 |