1 | <?php |
||
36 | class Collection extends AbstractShape implements CollectionInterface, IteratorAggregate, ArrayAccess, Countable, MultiValueInterface |
||
|
|||
37 | { |
||
38 | use Collection\AliasTrait; |
||
39 | use Collection\ArrayAccessTrait; |
||
40 | use Collection\CountableTrait; |
||
41 | use Collection\IteratorAggregateTrait; |
||
42 | use Collection\SeekableInterfaceTrait; |
||
43 | |||
44 | /** @var \ArrayObject */ |
||
45 | private $collection; |
||
46 | |||
47 | /** @var array */ |
||
48 | private $required_keys = []; |
||
49 | |||
50 | |||
51 | /**************************************************************************/ |
||
52 | // CONSTRUCTOR |
||
53 | |||
54 | /** |
||
55 | * Constructs a new instance of this class. |
||
56 | * |
||
57 | * @param array $value The standard array to convert into a collection. The default value is an empty string. |
||
58 | */ |
||
59 | public function __construct($value = []) |
||
67 | |||
68 | |||
69 | /**************************************************************************/ |
||
70 | // ShapeInterface |
||
71 | |||
72 | /** |
||
73 | * {@inheritdoc} |
||
74 | */ |
||
75 | public function validate() |
||
114 | |||
115 | /** |
||
116 | * {@inheritdoc} |
||
117 | */ |
||
118 | public function getValue() |
||
122 | |||
123 | /** |
||
124 | * The expected keys and data types of this shape. |
||
125 | * |
||
126 | * @return array The expected keys and data types of this shape. |
||
127 | */ |
||
128 | public function validateValue() |
||
133 | |||
134 | /** |
||
135 | * {@inheritdoc} |
||
136 | */ |
||
137 | public function requiredKeys() |
||
141 | |||
142 | /** |
||
143 | * {@inheritdoc} |
||
144 | */ |
||
145 | public function __toString() |
||
149 | |||
150 | /** |
||
151 | * Checks to see whether or not this is an indexed array (e.g., list). |
||
152 | * |
||
153 | * @return boolean Whether or not this Collection is a List. A value of `true` means that the Collection is an |
||
154 | * indexed array. A value of `false` means that the Collection is an associative array. |
||
155 | */ |
||
156 | public function isList() |
||
168 | |||
169 | /** |
||
170 | * Checks to see whether or not this is an associative array (e.g., hash, dictionary). |
||
171 | * |
||
172 | * @return boolean Whether or not this Collection is a Hash. A value of `true` means that the Collection is an |
||
173 | * associative array. A value of `false` means that the Collection is an indexed array. |
||
174 | */ |
||
175 | public function isMap() |
||
187 | |||
188 | |||
189 | /**************************************************************************/ |
||
190 | // Helper Methods |
||
191 | |||
192 | /** |
||
193 | * Stores the list of required keys for processing. |
||
194 | * |
||
195 | * @param array $keys The response from a call to `requiredKeys()`. |
||
196 | * @return void |
||
197 | */ |
||
198 | protected function storeRequiredKeys(array $keys) |
||
202 | |||
203 | /** |
||
204 | * Checks to see if a key is required. |
||
205 | * |
||
206 | * @param string $key The key to remove from the list of required keys. |
||
207 | * @return boolean Whether or not a key is required. A value of `true` means that the key is required. |
||
208 | * A value of `false` means that the key is NOT required. |
||
209 | */ |
||
210 | protected function isRequiredKey($key) |
||
214 | |||
215 | /** |
||
216 | * Plucks a key from the list of required keys, and returns the list of remaining keys. |
||
217 | * |
||
218 | * @param string $key The key to remove from the list of required keys. |
||
219 | * @return void |
||
220 | */ |
||
221 | protected function pluckFromRequiredKeys($key) |
||
227 | |||
228 | /** |
||
229 | * Gets the required keys that have not yet been set. |
||
230 | * |
||
231 | * @return array<string> The required keys that have not yet been set. |
||
232 | */ |
||
233 | protected function getRemainingRequiredKeys() |
||
237 | } |
||
238 |
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.