ArrayMap   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 19
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
A checkOffset() 0 4 2
1
<?php
2
3
namespace Diacdg\TypedArray;
4
5
class ArrayMap extends AbstractTypedArray
6
{
7
    protected $offsetType;
8
    
9 6
    public function __construct(string $offsetType, string $valueType, array $array = [], int $flags = 0, string $iteratorClass = "ArrayIterator")
10
    {
11 6
        $this->offsetType = $offsetType;
12 6
        $offsetAcceptedTypes = ['integer', 'string'];
13 6
        if (!in_array(strtolower($offsetType), $offsetAcceptedTypes)) {
14 1
            throw new \InvalidArgumentException('Offest type must be of type: ' . implode(', ', $offsetAcceptedTypes) . '.');
15
        }
16
17 5
        parent::__construct($valueType, $array, $flags, $iteratorClass);
18 5
    }
19
20 4
    protected function checkOffset($offset): void
21
    {
22 4
        if (gettype($offset) !== strtolower($this->offsetType)) {
23 1
            throw new \InvalidArgumentException('Offest must be of type: ' . $this->offsetType . '.');
24
        }
25
    }
26
}