1 | <?php |
||
12 | class Collection implements \IteratorAggregate, \Serializable, \Countable, \ArrayAccess |
||
13 | { |
||
14 | /** |
||
15 | * The elements of the collection. |
||
16 | * |
||
17 | * @var array |
||
18 | */ |
||
19 | private $elements; |
||
20 | |||
21 | /** |
||
22 | * extra properties that are not the main list but linked data |
||
23 | * It can be "_embed" or "_links" for HAL response |
||
24 | * or "hydra:totalItems" for JSON-LD |
||
25 | * or anything you want to really ("foo" is OK for exemple) |
||
26 | * |
||
27 | * @var array |
||
28 | * @access private |
||
29 | */ |
||
30 | private $extraProperties; |
||
31 | |||
32 | /** |
||
33 | * @param array $elements The data elements as an array. |
||
34 | * @param array $extraProperties The extra properties. |
||
35 | */ |
||
36 | public function __construct(array $elements = [], array $extraProperties = []) |
||
41 | |||
42 | /** |
||
43 | * Returns inner elements collection. |
||
44 | * |
||
45 | * @return array |
||
46 | */ |
||
47 | public function toArray() |
||
51 | |||
52 | /** |
||
53 | * {@inheritdoc} |
||
54 | */ |
||
55 | public function serialize() |
||
59 | |||
60 | /** |
||
61 | * {@inheritdoc} |
||
62 | */ |
||
63 | public function unserialize($values) |
||
67 | |||
68 | /** |
||
69 | * {@inheritdoc} |
||
70 | */ |
||
71 | public function count() |
||
75 | |||
76 | /** |
||
77 | * Returns element count in collection. |
||
78 | * |
||
79 | * @return int |
||
80 | */ |
||
81 | public function getTotalItems() |
||
85 | |||
86 | /** |
||
87 | * {@inheritdoc} |
||
88 | */ |
||
89 | public function offsetSet($offset, $value) |
||
97 | |||
98 | /** |
||
99 | * {@inheritdoc} |
||
100 | */ |
||
101 | public function offsetExists($offset) |
||
105 | |||
106 | /** |
||
107 | * {@inheritdoc} |
||
108 | */ |
||
109 | public function offsetUnset($offset) |
||
113 | |||
114 | /** |
||
115 | * {@inheritdoc} |
||
116 | */ |
||
117 | public function offsetGet($offset) |
||
121 | |||
122 | /** |
||
123 | * {@inheritdoc} |
||
124 | */ |
||
125 | public function getIterator() |
||
129 | |||
130 | /** |
||
131 | * getExtraProperties |
||
132 | * |
||
133 | * @access public |
||
134 | * @return array |
||
135 | */ |
||
136 | public function getExtraProperties() |
||
140 | |||
141 | /** |
||
142 | * return the value of an extra property |
||
143 | * |
||
144 | * @param string $key |
||
145 | * @access public |
||
146 | * @return mixed |
||
147 | */ |
||
148 | public function getExtraProperty($key) |
||
154 | } |
||
155 |