1 | <?php |
||
8 | final class Bag implements BagInterface, \JsonSerializable |
||
9 | { |
||
10 | /** |
||
11 | * @var array |
||
12 | */ |
||
13 | private $elements = []; |
||
14 | |||
15 | /** |
||
16 | * @var integer |
||
17 | */ |
||
18 | private $position; |
||
19 | |||
20 | /** |
||
21 | * Adds a new element to the bag. |
||
22 | * |
||
23 | * @param mixed $element The element to add. |
||
24 | * |
||
25 | * @return BagInterface |
||
26 | */ |
||
27 | public function add($element) : BagInterface |
||
33 | |||
34 | /** |
||
35 | * Removes a random element from the bag. |
||
36 | * |
||
37 | * @return mixed |
||
38 | * |
||
39 | * @throws \RuntimeException Thrown if remove is called on an empty bag. |
||
40 | */ |
||
41 | public function remove() |
||
49 | |||
50 | /** |
||
51 | * Returns true if the bag contains no elements. |
||
52 | * |
||
53 | * @return boolean |
||
54 | */ |
||
55 | public function isEmpty() : bool |
||
59 | |||
60 | /** |
||
61 | * @see \Iterator::rewind() |
||
62 | * |
||
63 | * @return void |
||
64 | */ |
||
65 | public function rewind() |
||
70 | |||
71 | /** |
||
72 | * @see \Iterator::current() |
||
73 | * |
||
74 | * @return mixed |
||
75 | */ |
||
76 | public function current() |
||
80 | |||
81 | /** |
||
82 | * @see \Iterator::key() |
||
83 | * |
||
84 | * @return integer |
||
85 | */ |
||
86 | public function key() : int |
||
90 | |||
91 | /** |
||
92 | * @see \Iterator::next() |
||
93 | * |
||
94 | * @return void |
||
95 | */ |
||
96 | public function next() |
||
100 | |||
101 | /** |
||
102 | * @see \Iterator::valid() |
||
103 | * |
||
104 | * @return boolean |
||
105 | */ |
||
106 | public function valid() : bool |
||
110 | |||
111 | /** |
||
112 | * @see \JsonSerializable::jsonSerialize() |
||
113 | * |
||
114 | * @return array |
||
115 | */ |
||
116 | public function jsonSerialize() : array |
||
120 | |||
121 | /** |
||
122 | * @see \Countable::count() |
||
123 | * |
||
124 | * @return integer |
||
125 | */ |
||
126 | public function count() : int |
||
130 | |||
131 | /** |
||
132 | * @see CollectionInterface::clear() |
||
133 | * |
||
134 | * @return CollectionInterface |
||
135 | */ |
||
136 | public function clear() : CollectionInterface |
||
141 | } |
||
142 |