Passed
Push — main ( e48091...6c9276 )
by Anatoly
05:36 queued 13s
created

Collection   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 8
c 1
b 0
f 0
dl 0
loc 26
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A offsetGet() 0 3 1
A offsetExists() 0 3 1
A offsetSet() 0 7 2
A offsetUnset() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Sunrise\Hydrator\Tests\Fixtures;
6
7
use ArrayAccess;
8
use OverflowException;
9
10
final class Collection implements ArrayAccess
11
{
12
    public array $elements = [];
13
14
    public function offsetExists($offset)
15
    {
16
        return isset($this->elements[$offset]);
17
    }
18
19
    public function offsetGet($offset)
20
    {
21
        return $this->elements[$offset] ?? null;
22
    }
23
24
    public function offsetSet($offset, $value)
25
    {
26
        if (!empty($this->elements)) {
27
            throw new OverflowException();
28
        }
29
30
        $this->elements[$offset] = $value;
31
    }
32
33
    public function offsetUnset($offset)
34
    {
35
        unset($this->elements[$offset]);
36
    }
37
}
38