Complex classes like Collection often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Collection, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
33 | class Collection implements ArrayAccess, Iterator, Countable, JsonSerializable |
||
34 | { |
||
35 | /** @var array The items for this collection */ |
||
36 | protected $items; |
||
37 | |||
38 | /** |
||
39 | * Collection constructor. |
||
40 | * |
||
41 | * @param array $items The items in the collection |
||
42 | */ |
||
43 | 100 | public function __construct(array $items = []) |
|
44 | { |
||
45 | 100 | $this->items = $items; |
|
46 | 100 | $this->rewind(); |
|
47 | 100 | } |
|
48 | |||
49 | /** |
||
50 | * Generate a collection from an array of items. |
||
51 | * I created this method so that it's possible to extend a collection more easily. |
||
52 | * |
||
53 | * @param mixed $items The items in the collection |
||
54 | * |
||
55 | * @return Collection |
||
56 | */ |
||
57 | 37 | public static function factory($items = null) |
|
58 | { |
||
59 | 37 | if (is_null($items)) { |
|
60 | 10 | $items = []; |
|
61 | 10 | } |
|
62 | 37 | return new Collection(to_array($items)); |
|
63 | } |
||
64 | |||
65 | /** |
||
66 | * Get collection as an array |
||
67 | * |
||
68 | * @return array |
||
69 | */ |
||
70 | 50 | public function toArray() |
|
71 | { |
||
72 | 50 | return $this->items; |
|
73 | } |
||
74 | |||
75 | /** |
||
76 | * Determine if collection has a given key |
||
77 | * |
||
78 | * @param mixed $key The key to look for |
||
79 | * |
||
80 | * @return bool |
||
81 | */ |
||
82 | 50 | public function has($key) |
|
83 | { |
||
84 | 50 | return isset($this->items[$key]) || array_key_exists($key, $this->items); |
|
85 | } |
||
86 | |||
87 | /** |
||
88 | * Does collection have item at position? |
||
89 | * |
||
90 | * Determine if collection has an item at a particular position (indexed from one). |
||
91 | * |
||
92 | * |
||
93 | * @param int $position Can be positive and start from the beginning or it can be negative and start from the end. |
||
94 | * Indexed from one (rather than zero). |
||
95 | * |
||
96 | * @return bool |
||
97 | */ |
||
98 | 2 | public function hasValueAt($position) |
|
99 | { |
||
100 | try { |
||
101 | 2 | $this->getKeyAt($position); |
|
102 | 2 | return true; |
|
103 | 2 | } catch (RuntimeException $e) { |
|
104 | 2 | return false; |
|
105 | } |
||
106 | } |
||
107 | |||
108 | /** |
||
109 | * Get key at given position |
||
110 | * |
||
111 | * Returns the key at the given position, starting from one. |
||
112 | * |
||
113 | * If the position does not exist, a RuntimeException is thrown. |
||
114 | * |
||
115 | * @param int $position Can be positive and start from the beginning or it can be negative and start from the end. |
||
116 | * Indexed from one (rather than zero). |
||
117 | * |
||
118 | * @return string |
||
119 | * |
||
120 | * @throws RuntimeException |
||
121 | */ |
||
122 | 6 | public function getKeyAt($position) |
|
123 | { |
||
124 | 6 | $collection = $this; |
|
125 | 6 | if ($position < 0) { |
|
126 | 3 | $collection = $this->reverse(); |
|
127 | 3 | } |
|
128 | 6 | $i = 1; |
|
129 | 6 | foreach ($collection as $key => $val) { |
|
130 | 6 | if (abs($position) == $i++) { |
|
131 | 5 | return $key; |
|
132 | } |
||
133 | 6 | } |
|
134 | 3 | throw new RuntimeException("No key at position {$position}"); |
|
135 | } |
||
136 | |||
137 | /** |
||
138 | * Get value at given position |
||
139 | * |
||
140 | * Returns the value at the given position, starting from one. |
||
141 | * |
||
142 | * If the position does not exist, a RuntimeException is thrown. |
||
143 | * |
||
144 | * @param int $position Can be positive and start from the beginning or it can be negative and start from the end. |
||
145 | * Indexed from one (rather than zero). |
||
146 | * |
||
147 | * @return mixed |
||
148 | * |
||
149 | * @throws RuntimeException |
||
150 | */ |
||
151 | 2 | public function getValueAt($position) |
|
152 | { |
||
153 | 2 | return $this->get($this->getKeyAt($position)); |
|
154 | } |
||
155 | |||
156 | /** |
||
157 | * Get the key of the first item found matching $item |
||
158 | * |
||
159 | * @param mixed|callable $item The item value to look for |
||
160 | * |
||
161 | * @return mixed|null |
||
162 | */ |
||
163 | 3 | public function keyOf($item) |
|
164 | { |
||
165 | 3 | $index = 0; |
|
166 | 3 | foreach ($this as $key => $val) { |
|
167 | 3 | if (is_callable($item)) { |
|
168 | 1 | if ($item($val, $key, $index++)) { |
|
169 | 1 | return $key; |
|
170 | } |
||
171 | 3 | } elseif ($item === $val) { |
|
172 | 1 | return $key; |
|
173 | } |
||
174 | 3 | } |
|
175 | |||
176 | 1 | throw new RuntimeException("No item found at given key: {$item}"); |
|
177 | } |
||
178 | |||
179 | /** |
||
180 | * Get the offset (index) of the first item found that matches $item |
||
181 | * |
||
182 | * @param mixed|callable $item The item value to look for |
||
183 | * |
||
184 | * @return int|null |
||
185 | */ |
||
186 | 3 | public function indexOf($item) |
|
187 | { |
||
188 | 3 | $index = 0; |
|
189 | 3 | foreach ($this as $key => $val) { |
|
190 | 3 | if (is_callable($item)) { |
|
191 | 1 | if ($item($val, $key, $index)) { |
|
192 | 1 | return $index; |
|
193 | } |
||
194 | 1 | } else { |
|
195 | 2 | if ($item === $val) { |
|
196 | 1 | return $index; |
|
197 | } |
||
198 | } |
||
199 | 3 | $index++; |
|
200 | 3 | } |
|
201 | |||
202 | 1 | throw new RuntimeException("No key found for given item: {$item}"); |
|
203 | } |
||
204 | |||
205 | /** |
||
206 | * Get item by key, with an optional default return value |
||
207 | * |
||
208 | * @param mixed $key The key of the item you want |
||
209 | * @param mixed $default A default to return if key does not exist |
||
210 | * |
||
211 | * @return mixed |
||
212 | */ |
||
213 | 8 | public function get($key, $default = null) |
|
214 | { |
||
215 | 8 | if ($this->has($key)) { |
|
216 | 8 | return $this->items[$key]; |
|
217 | } |
||
218 | |||
219 | 3 | return $default; |
|
220 | } |
||
221 | |||
222 | /** |
||
223 | * Add an item with no regard to key |
||
224 | * |
||
225 | * Simply adds a value at the end of the collection. A numeric index will be created automatically. |
||
226 | * |
||
227 | * @param mixed $value The value to add to the collection |
||
228 | * |
||
229 | * @return self |
||
230 | */ |
||
231 | 8 | public function add($value) |
|
237 | |||
238 | /** |
||
239 | * Set an item at a given key |
||
240 | * |
||
241 | * Sets the specified key to the specified value. By default the key will be overwritten if it already exists, but |
||
242 | * this behavior may be changed by setting the third parameter ($overwrite) to false. |
||
243 | * |
||
244 | * @param mixed $key The desired key |
||
245 | * @param mixed $value The desired value to set the key to |
||
246 | * @param bool $overwrite If false, do not overwrite existing key |
||
247 | * |
||
248 | * @return self |
||
249 | */ |
||
250 | 14 | public function set($key, $value, $overwrite = true) |
|
258 | |||
259 | /** |
||
260 | * Delete an item by key |
||
261 | * |
||
262 | * @param mixed $key The key whose value you want to delete |
||
263 | * |
||
264 | * @return self |
||
265 | */ |
||
266 | 3 | public function delete($key) |
|
272 | |||
273 | /** |
||
274 | * Clear the collection of all its items. |
||
275 | * |
||
276 | * @return self |
||
277 | */ |
||
278 | 2 | public function clear() |
|
284 | |||
285 | /** |
||
286 | * Determine if collection contains given value |
||
287 | * |
||
288 | * Used to determine if the collection contains a given value. Or, for more complex use cases, a callback may be |
||
289 | * provided in place of a value, which will be used to determine a match. |
||
290 | * |
||
291 | * You may also provide a key as the second argument if you wish to match a key as well. |
||
292 | * |
||
293 | * @param mixed|callable $val The value to search for or a callback used to determine a match |
||
294 | * @param mixed $key The (optional) key to match |
||
295 | * |
||
296 | * @return bool |
||
297 | */ |
||
298 | 4 | public function contains($val, $key = null) |
|
316 | |||
317 | /** |
||
318 | * Fetch item by key and remove it from the collection |
||
319 | * |
||
320 | * @param mixed $key The keyof the value you would like to pull |
||
321 | * |
||
322 | * @return mixed |
||
323 | */ |
||
324 | 1 | public function pull($key) |
|
332 | |||
333 | /** |
||
334 | * Join collection items using a delimiter |
||
335 | * |
||
336 | * @param string $delim The character(s) to delimit the results with |
||
337 | * |
||
338 | * @return string |
||
339 | */ |
||
340 | 1 | public function join($delim = '') |
|
344 | |||
345 | /** |
||
346 | * Determine if collection is empty |
||
347 | * |
||
348 | * @return bool |
||
349 | */ |
||
350 | 5 | public function isEmpty() |
|
354 | |||
355 | /** |
||
356 | * Get only collection's values |
||
357 | * |
||
358 | * Return a new collection with only the current collection's values. The keys will be indexed numerically from zero |
||
359 | * |
||
360 | * @return Collection |
||
361 | */ |
||
362 | 1 | public function values() |
|
366 | |||
367 | /** |
||
368 | * Get only collection's keys |
||
369 | * |
||
370 | * Return a new collection with only the current collection's keys as its values. The new collection's keys will be |
||
371 | * indexed numerically from zero. |
||
372 | * |
||
373 | * @return Collection |
||
374 | */ |
||
375 | 1 | public function keys() |
|
379 | |||
380 | /** |
||
381 | * Get a collection with order reversed |
||
382 | * |
||
383 | * @return Collection |
||
384 | */ |
||
385 | 6 | public function reverse() |
|
389 | |||
390 | /** |
||
391 | * Get a collection with keys and values flipped. |
||
392 | * |
||
393 | * Returns a new collection containing the keys as values and the values as keys. |
||
394 | * |
||
395 | * @return Collection |
||
396 | */ |
||
397 | 1 | public function flip() |
|
405 | |||
406 | /** |
||
407 | * Shuffle (randomize) the order of this collection's values (in-place) |
||
408 | * |
||
409 | * @return Collection |
||
410 | */ |
||
411 | 1 | public function shuffle() |
|
416 | |||
417 | /** |
||
418 | * Get a random value from the collection |
||
419 | * |
||
420 | * @return mixed |
||
421 | */ |
||
422 | 1 | public function random() |
|
426 | |||
427 | /** |
||
428 | * Sort the collection's values (in-place) |
||
429 | * |
||
430 | * Sorts the collection by value using the provided algorithm (which can be either the name of a native php function |
||
431 | * or a callable). |
||
432 | * |
||
433 | * @param callable $alg The sorting algorithm (defaults to strcmp) |
||
434 | * |
||
435 | * @return self |
||
436 | */ |
||
437 | 2 | public function sort(callable $alg = null) |
|
447 | |||
448 | /** |
||
449 | * Sort the collection's keys (in-place) |
||
450 | * |
||
451 | * Sorts the collection by key using the provided algorithm (which can be either the name of a native php function |
||
452 | * or a callable). |
||
453 | * |
||
454 | * @param callable $alg The sorting algorithm (defaults to strcmp) |
||
455 | * |
||
456 | * @return self |
||
457 | */ |
||
458 | 2 | public function ksort(callable $alg = null) |
|
468 | |||
469 | /** |
||
470 | * Append items to collection without regard to key |
||
471 | * |
||
472 | * @param array|Traversable $items A list of values to append to the collection |
||
473 | * |
||
474 | * @return self |
||
475 | */ |
||
476 | 2 | public function append($items) |
|
488 | |||
489 | /** |
||
490 | * Return first item or first item where callback returns true |
||
491 | * |
||
492 | * Returns the first item in the collection or, if passed a callback, the first item that causes the callback to |
||
493 | * return true. |
||
494 | * |
||
495 | * @param callable|null $callback A callback to compare items with |
||
496 | * |
||
497 | * @return mixed|null |
||
498 | */ |
||
499 | 8 | public function first(callable $callback = null) |
|
510 | |||
511 | /** |
||
512 | * Return last item or last item where callback returns true |
||
513 | * |
||
514 | * Returns the last item in the collection or, if passed a callback, the last item that causes the callback to |
||
515 | * return true. |
||
516 | * |
||
517 | * @param callable|null $callback A callback to compare items with |
||
518 | * |
||
519 | * @return mixed|null |
||
520 | */ |
||
521 | 3 | public function last(callable $callback = null) |
|
525 | |||
526 | /** |
||
527 | * Map collection |
||
528 | * |
||
529 | * Create a new collection using the results of a callback function on each item in this collection. |
||
530 | * |
||
531 | * @param callable $callback A callback to generate the new values |
||
532 | * |
||
533 | * @return Collection |
||
534 | */ |
||
535 | 3 | public function map(callable $callback) |
|
546 | |||
547 | /** |
||
548 | * Combine collection with another traversable/collection |
||
549 | * |
||
550 | * Using this collection's keys, and the incoming collection's values, a new collection is created and returned. |
||
551 | * |
||
552 | * @param array|Traversable $items The values to combine with this collection's keys |
||
553 | * |
||
554 | * @return Collection |
||
555 | */ |
||
556 | 5 | public function combine($items) |
|
569 | |||
570 | /** |
||
571 | * Get a new collection with only distinct values |
||
572 | * |
||
573 | * @return Collection |
||
574 | */ |
||
575 | 1 | public function distinct() |
|
586 | |||
587 | /** |
||
588 | * Remove all duplicate values from collection (in-place) |
||
589 | * |
||
590 | * @return Collection |
||
591 | */ |
||
592 | 1 | public function deduplicate() |
|
598 | |||
599 | /** |
||
600 | * Return a new collection with only filtered keys/values |
||
601 | * |
||
602 | * The callback accepts value, key, index and should return true if the item should be added to the returned |
||
603 | * collection |
||
604 | * |
||
605 | * @param callable $callback The callback used to filter with |
||
606 | * |
||
607 | * @return Collection |
||
608 | */ |
||
609 | 2 | public function filter(callable $callback = null) |
|
627 | |||
628 | /** |
||
629 | * Fold collection into a single value (a.k.a. reduce) |
||
630 | * |
||
631 | * Loop through collection calling a callback function and passing the result to the next iteration, eventually |
||
632 | * returning a single value. |
||
633 | * |
||
634 | * @param callable $callback The callback used to "fold" or "reduce" the collection into a single value |
||
635 | * @param mixed $initial The (optional) initial value to pass to the callback |
||
636 | * |
||
637 | * @return null |
||
638 | */ |
||
639 | 1 | public function fold(callable $callback, $initial = null) |
|
649 | |||
650 | /** |
||
651 | * Return a merge of this collection and $items |
||
652 | * |
||
653 | * Returns a new collection with a merge of this collection and $items. Values from $items will overwrite values in |
||
654 | * the current collection. |
||
655 | * |
||
656 | * @param array|Traversable $items The items to merge with the collection |
||
657 | * |
||
658 | * @return Collection |
||
659 | */ |
||
660 | 3 | public function merge($items) |
|
673 | |||
674 | /** |
||
675 | * Create a new collection with a union of this collection and $items |
||
676 | * |
||
677 | * This method is similar to merge, except that existing values will not be overwritten. |
||
678 | * |
||
679 | * @param $items |
||
680 | */ |
||
681 | 2 | public function union($items) |
|
694 | |||
695 | /** |
||
696 | * Call callback for each item in collection, passively |
||
697 | * |
||
698 | * If at any point the callback returns false, iteration stops. |
||
699 | * |
||
700 | * @param callable $callback The callback to use on each item in the collection |
||
701 | * |
||
702 | * @return self |
||
703 | */ |
||
704 | 2 | public function each(callable $callback) |
|
715 | |||
716 | /** |
||
717 | * Assert callback returns $expected value for each item in collection. |
||
718 | * |
||
719 | * This method will loop over each item in the collection, passing them to the callback. If the callback doesn't |
||
720 | * return $expected value for every item in the collection, it will return false. |
||
721 | * |
||
722 | * @param callable $callback Assertion callback |
||
723 | * @param bool $expected Expected value from callback |
||
724 | * |
||
725 | * @return bool |
||
726 | */ |
||
727 | 2 | public function assert(callable $callback, $expected = true) |
|
738 | |||
739 | /** |
||
740 | * Pipe collection through a callback |
||
741 | * |
||
742 | * Simply passes the collection as an argument to the given callback. |
||
743 | * |
||
744 | * @param callable $callback The callback function |
||
745 | * |
||
746 | * @return mixed |
||
747 | */ |
||
748 | 1 | public function pipe(callable $callback) |
|
752 | |||
753 | /** |
||
754 | * Get new collection in chunks of $size |
||
755 | * |
||
756 | * Creates a new collection of arrays of $size length. The remainder items will be placed at the end. |
||
757 | * |
||
758 | * @param int $size The size of the arrays you want returned |
||
759 | * |
||
760 | * @return Collection |
||
761 | */ |
||
762 | 2 | public function chunk($size) |
|
766 | |||
767 | /** |
||
768 | * Get a new collection of $count chunks |
||
769 | * |
||
770 | * Returns a collection of $count number of equally-sized arrays, placing remainders at the end. |
||
771 | * |
||
772 | * @param int $count The number of arrays you want returned |
||
773 | * |
||
774 | * @return Collection |
||
775 | */ |
||
776 | 1 | public function split($count = 1) |
|
780 | |||
781 | /** |
||
782 | * Get a slice of this collection. |
||
783 | * |
||
784 | * Returns a collection with a slice of this collection's items, starting at $offset and continuing until $length |
||
785 | * |
||
786 | * @param int $offset The offset at which you want the slice to begin |
||
787 | * @param int|null $length The length of the slice (number of items) |
||
788 | * |
||
789 | * @return Collection |
||
790 | */ |
||
791 | 1 | public function slice($offset, $length = null) |
|
795 | |||
796 | /** |
||
797 | * Get collection with only differing items |
||
798 | * |
||
799 | * Returns a collection containing only the items not present in *both* this collection and $items. |
||
800 | * |
||
801 | * @param array|Traversable $items The items to compare with |
||
802 | * |
||
803 | * @return Collection |
||
804 | */ |
||
805 | 1 | public function diff($items) |
|
809 | |||
810 | /** |
||
811 | * Get collection with only differing items (by key) |
||
812 | * |
||
813 | * Returns a collection containing only the values whose keys are not present in *both* this collection and $items. |
||
814 | * |
||
815 | * @param array|Traversable $items The items to compare with |
||
816 | * |
||
817 | * @return Collection |
||
818 | */ |
||
819 | 2 | public function kdiff($items) |
|
823 | |||
824 | /** |
||
825 | * Get collection with only intersecting items |
||
826 | * |
||
827 | * Returns a collection containing only the values present in *both* this collection and $items |
||
828 | * |
||
829 | * @param array|Traversable $items The items to compare with |
||
830 | * |
||
831 | * @return Collection |
||
832 | */ |
||
833 | 1 | public function intersect($items) |
|
837 | |||
838 | /** |
||
839 | * Get collection with only intersecting items (by key) |
||
840 | * |
||
841 | * Returns a collection containing only the values whose keys are present in *both* this collection and $items |
||
842 | * |
||
843 | * @param array|Traversable $items The items to compare with |
||
844 | * |
||
845 | * @return Collection |
||
846 | */ |
||
847 | 1 | public function kintersect($items) |
|
851 | |||
852 | /** |
||
853 | * Remove last item in collection and return it |
||
854 | * |
||
855 | * @return mixed |
||
856 | */ |
||
857 | 1 | public function pop() |
|
861 | |||
862 | /** |
||
863 | * Remove first item in collection and return it |
||
864 | * |
||
865 | * If the collection is numerically indexed, this method will re-index it from 0 after returning the item. |
||
866 | * |
||
867 | * @return mixed |
||
868 | */ |
||
869 | 2 | public function shift() |
|
873 | |||
874 | /** |
||
875 | * Add item to the end of the collection |
||
876 | * |
||
877 | * @note This method is no different than add() but I included it for consistency's sake since I have the others |
||
878 | * |
||
879 | * @param mixed $item The item to add to the collection |
||
880 | * |
||
881 | * @return self |
||
882 | */ |
||
883 | 1 | public function push($item) |
|
887 | |||
888 | /** |
||
889 | * Add item to the beginning of the collection |
||
890 | * |
||
891 | * The collection will be re-indexed if it has numeric keys. |
||
892 | * |
||
893 | * @param mixed $item The item to add to the collection |
||
894 | * |
||
895 | * @return self |
||
896 | */ |
||
897 | 5 | public function unshift($item) |
|
903 | |||
904 | /** |
||
905 | * Get new collection padded to specified $size with $value |
||
906 | * |
||
907 | * Using $value, pad the collection to specified $size. If $size is smaller or equal to the size of the collection, |
||
908 | * then no padding takes place. If $size is positive, padding is added to the end, while if negative, padding will |
||
909 | * be added to the beginning. |
||
910 | * |
||
911 | * @param int $size The number of items collection should have |
||
912 | * @param mixed $value The value to pad with |
||
913 | * |
||
914 | * @return Collection |
||
915 | */ |
||
916 | 3 | public function pad($size, $value = null) |
|
929 | |||
930 | /** |
||
931 | * Partition collection into two collections using a callback |
||
932 | * |
||
933 | * Iterates over each element in the collection with a callback. Items where callback returns true are placed in one |
||
934 | * collection and the rest in another. Finally, the two collections are placed in an array and returned for easy use |
||
935 | * with the list() function. ( list($a, $b) = $col->partition(function($val, $key, $index) {}) ) |
||
936 | * |
||
937 | * @param callable $callback The comparison callback |
||
938 | * |
||
939 | * @return Collection[] |
||
940 | */ |
||
941 | 2 | public function partition(callable $callback) |
|
957 | |||
958 | /** |
||
959 | * Get column values by key |
||
960 | * |
||
961 | * This method expects the collection's data to be tabular in nature (two-dimensional and for the rows to have |
||
962 | * consistently named keys). If the data is not structured this way, it will do the best it can but it is not meant |
||
963 | * for unstructured, non-tabular data so don't expect consistent results. |
||
964 | * |
||
965 | * @param string|int $column The key of the column you want to get |
||
966 | * |
||
967 | * @return Collection |
||
968 | */ |
||
969 | 3 | public function getColumn($column) |
|
973 | |||
974 | /** |
||
975 | * Is collection tabular? |
||
976 | * |
||
977 | * Returns true if the data in the collection is tabular in nature, meaning it is at least two-dimensional and each |
||
978 | * row contains the same number of values with the same keys. |
||
979 | * |
||
980 | * @return bool |
||
981 | */ |
||
982 | 1 | public function isTabular() |
|
994 | |||
995 | /** ++++ ++++ **/ |
||
996 | /** ++ Interface Compliance ++ **/ |
||
997 | /** ++++ ++++ **/ |
||
998 | |||
999 | /** |
||
1000 | * JSON serialize |
||
1001 | * |
||
1002 | * @return array |
||
1003 | */ |
||
1004 | 1 | public function jsonSerialize() |
|
1008 | |||
1009 | /** ++++ ++++ **/ |
||
1010 | /** ++ Array Access Methods ++ **/ |
||
1011 | /** ++++ ++++ **/ |
||
1012 | |||
1013 | /** |
||
1014 | * Does offset exist? |
||
1015 | * |
||
1016 | * @param mixed $offset |
||
1017 | * |
||
1018 | * @return bool |
||
1019 | */ |
||
1020 | 1 | public function offsetExists($offset) |
|
1024 | |||
1025 | /** |
||
1026 | * Get item at offset |
||
1027 | * |
||
1028 | * @param mixed $offset |
||
1029 | * |
||
1030 | * @return mixed |
||
1031 | */ |
||
1032 | 2 | public function offsetGet($offset) |
|
1040 | |||
1041 | /** |
||
1042 | * Unset item at offset |
||
1043 | * |
||
1044 | * @param mixed $offset |
||
1045 | * |
||
1046 | * @return void |
||
1047 | */ |
||
1048 | 1 | public function offsetUnset($offset) |
|
1052 | |||
1053 | /** |
||
1054 | * Set item at offset |
||
1055 | * |
||
1056 | * @param mixed $offset |
||
1057 | * @param mixed $value |
||
1058 | * |
||
1059 | * @return self |
||
1060 | */ |
||
1061 | 1 | public function offsetSet($offset, $value) |
|
1069 | |||
1070 | /** ++++ ++++ **/ |
||
1071 | /** ++ Iterator Methods ++ **/ |
||
1072 | /** ++++ ++++ **/ |
||
1073 | |||
1074 | /** |
||
1075 | * @ignore |
||
1076 | */ |
||
1077 | 38 | public function current() |
|
1081 | |||
1082 | /** |
||
1083 | * @ignore |
||
1084 | */ |
||
1085 | 38 | public function key() |
|
1089 | |||
1090 | /** |
||
1091 | * @ignore |
||
1092 | */ |
||
1093 | 37 | public function next() |
|
1097 | |||
1098 | /** |
||
1099 | * @ignore |
||
1100 | */ |
||
1101 | 100 | public function rewind() |
|
1105 | |||
1106 | /** |
||
1107 | * @ignore |
||
1108 | */ |
||
1109 | 39 | public function valid() |
|
1113 | |||
1114 | /** ++++ ++++ **/ |
||
1115 | /** ++ Countable Method ++ **/ |
||
1116 | /** ++++ ++++ **/ |
||
1117 | |||
1118 | /** |
||
1119 | * Get number of items in the collection |
||
1120 | * |
||
1121 | * @return int |
||
1122 | */ |
||
1123 | 11 | public function count() |
|
1127 | } |