1 | <?php |
||
15 | class ParserCollection extends AbstractSearcher implements \Countable, \Iterator, \ArrayAccess |
||
16 | { |
||
17 | use SearcherTrait; |
||
18 | |||
19 | private $values = []; |
||
20 | |||
21 | private $position = 0; |
||
22 | |||
23 | /** |
||
24 | * This constructor is there in order to be able to create a collection with |
||
25 | * its values already added |
||
26 | */ |
||
27 | public function __construct(array $values = []) |
||
33 | |||
34 | /** |
||
35 | * Implementation of method declared in \Countable. |
||
36 | * Provides support for count() |
||
37 | */ |
||
38 | public function count() |
||
42 | |||
43 | /** |
||
44 | * Implementation of method declared in \Iterator |
||
45 | * Resets the internal cursor to the beginning of the array |
||
46 | */ |
||
47 | public function rewind() |
||
51 | |||
52 | /** |
||
53 | * Implementation of method declared in \Iterator |
||
54 | * Used to get the current key (as for instance in a foreach()-structure |
||
55 | */ |
||
56 | public function key() |
||
60 | |||
61 | /** |
||
62 | * Implementation of method declared in \Iterator |
||
63 | * Used to get the value at the current cursor position |
||
64 | */ |
||
65 | public function current() |
||
69 | |||
70 | /** |
||
71 | * Implementation of method declared in \Iterator |
||
72 | * Used to move the cursor to the next position |
||
73 | */ |
||
74 | public function next() |
||
78 | |||
79 | /** |
||
80 | * Implementation of method declared in \Iterator |
||
81 | * Checks if the current cursor position is valid |
||
82 | */ |
||
83 | public function valid() |
||
87 | |||
88 | /** |
||
89 | * Implementation of method declared in \ArrayAccess |
||
90 | * Used to be able to use functions like isset() |
||
91 | */ |
||
92 | public function offsetExists($offset) |
||
96 | |||
97 | /** |
||
98 | * Implementation of method declared in \ArrayAccess |
||
99 | * Used for direct access array-like ($collection[$offset]); |
||
100 | */ |
||
101 | public function offsetGet($offset) |
||
105 | |||
106 | /** |
||
107 | * Implementation of method declared in \ArrayAccess |
||
108 | * Used for direct setting of values |
||
109 | */ |
||
110 | public function offsetSet($offset, $value) |
||
122 | |||
123 | /** |
||
124 | * Implementation of method declared in \ArrayAccess |
||
125 | * Used for unset() |
||
126 | */ |
||
127 | public function offsetUnset($offset) |
||
131 | |||
132 | } |