| Total Complexity | 13 |
| Total Lines | 64 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 6 | class ProductCollection implements \Countable, \Iterator, \ArrayAccess |
||
| 7 | { |
||
| 8 | private $products; |
||
| 9 | private $position; |
||
| 10 | |||
| 11 | public function __construct(array $productCandidates = []) |
||
| 12 | { |
||
| 13 | foreach ($productCandidates as $candidate) { |
||
| 14 | $this->offsetSet('', new Product(json_decode(json_encode($candidate), true))); |
||
| 15 | } |
||
| 16 | } |
||
| 17 | |||
| 18 | public function count() |
||
| 19 | { |
||
| 20 | return count($this->products); |
||
| 21 | } |
||
| 22 | |||
| 23 | public function current() |
||
| 24 | { |
||
| 25 | return $this->products[$this->position]; |
||
| 26 | } |
||
| 27 | |||
| 28 | public function next() |
||
| 29 | { |
||
| 30 | $this->position++; |
||
| 31 | } |
||
| 32 | |||
| 33 | public function key() |
||
| 36 | } |
||
| 37 | |||
| 38 | public function rewind() : void |
||
| 39 | { |
||
| 40 | $this->position = 0; |
||
| 41 | } |
||
| 42 | |||
| 43 | public function valid() |
||
| 46 | } |
||
| 47 | |||
| 48 | public function offsetExists($offset) : bool |
||
| 51 | } |
||
| 52 | |||
| 53 | public function offsetGet($offset) : mixed |
||
| 56 | } |
||
| 57 | |||
| 58 | public function offsetSet($offset, $product) |
||
| 64 | } |
||
| 65 | } |
||
| 66 | |||
| 67 | public function offsetUnset($offset) |
||
| 70 | } |
||
| 71 | } |
||
| 72 |