Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
5 / 5
CRAP
100.00% covered (success)
100.00%
1 / 1
ProductInterfaceArrayAccess
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
5 / 5
5
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 offsetExists
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 offsetGet
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 offsetSet
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 offsetUnset
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace Alistaircol\Hta\Domain\Basket\DataTransferObjects;
6
7use Alistaircol\Hta\Domain\Basket\Concerns\ProductInterface;
8use ArrayIterator;
9
10abstract class ProductInterfaceArrayAccess implements ProductInterfaceArrayAccessInterface
11{
12    protected ArrayIterator $iterator;
13
14    public function __construct(array $collection = [])
15    {
16        $this->iterator = new ArrayIterator($collection);
17    }
18
19    public function offsetExists(string $offset): bool
20    {
21        return $this->iterator->offsetExists($offset);
22    }
23
24    public function offsetGet(string $offset): ?ProductInterface
25    {
26        return $this->iterator[$offset] ?? null;
27    }
28
29    public function offsetSet(string $offset, ProductInterface $value): void
30    {
31        $this->iterator[$offset] = $value;
32    }
33
34    public function offsetUnset(string $offset): void
35    {
36        unset($this->iterator[$offset]);
37    }
38}