| Total Complexity | 12 |
| Total Lines | 111 |
| Duplicated Lines | 0 % |
| Coverage | 8% |
| Changes | 0 | ||
| 1 | <?php |
||
| 5 | abstract class Bag implements \Countable, \SeekableIterator, \Serializable, \JsonSerializable |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * |
||
| 9 | * @var array |
||
| 10 | */ |
||
| 11 | protected $data = []; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * |
||
| 15 | * @return int |
||
| 16 | */ |
||
| 17 | public function count(): int |
||
| 18 | { |
||
| 19 | return count($this->data); |
||
| 20 | } |
||
| 21 | |||
| 22 | |||
| 23 | /** |
||
| 24 | * |
||
| 25 | * @param int $key |
||
| 26 | * @return int |
||
| 27 | */ |
||
| 28 | public function seek($key) |
||
| 29 | { |
||
| 30 | if (!isset($this->data[$key])) { |
||
| 31 | throw new \OutOfBoundsException; |
||
| 32 | } |
||
| 33 | |||
| 34 | return $key; |
||
|
|
|||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * |
||
| 39 | * @return mixed |
||
| 40 | */ |
||
| 41 | public function current() |
||
| 42 | { |
||
| 43 | return current($this->data); |
||
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * |
||
| 48 | * @return mixed |
||
| 49 | */ |
||
| 50 | public function next() |
||
| 51 | { |
||
| 52 | return next($this->data); |
||
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * |
||
| 57 | * @return mixed |
||
| 58 | */ |
||
| 59 | public function key() |
||
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * |
||
| 66 | * @return bool |
||
| 67 | */ |
||
| 68 | public function valid(): bool |
||
| 69 | { |
||
| 70 | return null !== key($this->data); |
||
| 71 | } |
||
| 72 | |||
| 73 | /** |
||
| 74 | * |
||
| 75 | * @return mixed |
||
| 76 | */ |
||
| 77 | public function rewind() |
||
| 78 | { |
||
| 79 | return reset($this->data); |
||
| 80 | } |
||
| 81 | |||
| 82 | /** |
||
| 83 | * |
||
| 84 | * @return string |
||
| 85 | */ |
||
| 86 | public function serialize(): string |
||
| 87 | { |
||
| 88 | return serialize($this->data); |
||
| 89 | } |
||
| 90 | |||
| 91 | /** |
||
| 92 | * |
||
| 93 | * @param string $serialized |
||
| 94 | */ |
||
| 95 | public function unserialize($serialized) |
||
| 98 | } |
||
| 99 | |||
| 100 | /** |
||
| 101 | * |
||
| 102 | * @return array |
||
| 103 | */ |
||
| 104 | public function jsonSerialize(): array |
||
| 105 | { |
||
| 106 | return $this->data; |
||
| 107 | } |
||
| 108 | |||
| 109 | /** |
||
| 110 | * |
||
| 111 | * @return array |
||
| 112 | */ |
||
| 113 | 17 | public function __toArray(): array |
|
| 116 | } |
||
| 117 | } |
||
| 118 |
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: