1 | <?php |
||
11 | class Bag implements \IteratorAggregate, \Countable, \ArrayAccess |
||
12 | { |
||
13 | /** |
||
14 | * @var array |
||
15 | */ |
||
16 | protected $elements; |
||
17 | |||
18 | /** |
||
19 | * @param array $elements |
||
20 | */ |
||
21 | 33 | public function __construct(array $elements = array()) |
|
25 | |||
26 | /** |
||
27 | * @param array $elements |
||
28 | */ |
||
29 | 33 | public function setData(array $elements) |
|
33 | |||
34 | /** |
||
35 | * @param mixed $element |
||
36 | * |
||
37 | * @return $this |
||
38 | */ |
||
39 | 7 | public function add($element) |
|
45 | |||
46 | /** |
||
47 | * Returns last element.. |
||
48 | * |
||
49 | * @return string |
||
50 | */ |
||
51 | 3 | public function last() |
|
55 | |||
56 | /** |
||
57 | * Returns second last element. |
||
58 | * |
||
59 | * @return string | false |
||
60 | */ |
||
61 | 3 | public function secondLast() |
|
67 | |||
68 | /** |
||
69 | * Returns first element. |
||
70 | * |
||
71 | * @return string |
||
72 | */ |
||
73 | 3 | public function first() |
|
77 | |||
78 | /** |
||
79 | * Returns number of all elements. |
||
80 | * |
||
81 | * @return int |
||
82 | */ |
||
83 | 7 | public function count() |
|
87 | |||
88 | /** |
||
89 | * @return \ArrayIterator|\Traversable |
||
90 | */ |
||
91 | 2 | public function getIterator() |
|
95 | |||
96 | /** |
||
97 | * @param int $offset |
||
98 | * |
||
99 | * @return bool |
||
100 | */ |
||
101 | 2 | public function offsetExists($offset) |
|
105 | |||
106 | /** |
||
107 | * @param int $offset |
||
108 | * |
||
109 | * @return mixed |
||
110 | */ |
||
111 | 2 | public function offsetGet($offset) |
|
115 | |||
116 | /** |
||
117 | * @param int $offset |
||
118 | * @param mixed $value |
||
119 | */ |
||
120 | 1 | public function offsetSet($offset, $value) |
|
124 | |||
125 | /** |
||
126 | * @param int $offset |
||
127 | */ |
||
128 | 1 | public function offsetUnset($offset) |
|
132 | |||
133 | /** |
||
134 | * Removes all elements. |
||
135 | * |
||
136 | * @return $this |
||
137 | */ |
||
138 | 1 | public function clear() |
|
144 | |||
145 | /** |
||
146 | * @return bool |
||
147 | */ |
||
148 | 3 | public function isEmpty() |
|
152 | |||
153 | /** |
||
154 | * @return array |
||
155 | */ |
||
156 | 4 | public function all() |
|
160 | |||
161 | /** |
||
162 | * @param mixed $needle |
||
163 | * |
||
164 | * @return bool |
||
165 | */ |
||
166 | 1 | public function exists($needle) |
|
176 | |||
177 | /** |
||
178 | * @return string |
||
179 | */ |
||
180 | 2 | public function __toString() |
|
184 | } |
||
185 |