Passed
Push — master ( e86fff...e18c6a )
by Petr
01:43
created

ArrayList::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 8
Ratio 100 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 8
loc 8
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php declare(strict_types=1);
2
namespace Vehsamrak\ListCollection;
3
4
use Vehsamrak\ListCollection\Exceptions\InvalidTypeException;
5
6
/**
7
 * List which contains only arrays
8
 */
9 View Code Duplication
class ArrayList extends AbstractTypedList
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
10
{
11 24
    public function __construct(array $elements = [])
12
    {
13 24
        foreach ($elements as $element) {
14 7
            $this->checkType($element);
15
        }
16
17 19
        parent::__construct($elements);
18 19
    }
19
20
    /** @inheritDoc */
21 21
    public function checkType($element): void
22
    {
23 21
        if (!is_array($element)) {
24 15
            throw new InvalidTypeException(
25 15
                sprintf('Element "%s" is not an object', json_encode($element))
26
            );
27
        }
28 6
    }
29
}
30