StubSet::add()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 14
ccs 8
cts 8
cp 1
crap 2
rs 9.7998
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Moka\Stub;
5
6
use Moka\Exception\InvalidArgumentException;
7
use PhpCollection\Set;
8
9
/**
10
 * Class StubSet
11
 * @package Moka\Stub
12
 */
13
class StubSet extends Set
14
{
15
    /**
16
     * @param StubInterface $elem
17
     * @return void
18
     *
19
     * @throws InvalidArgumentException
20
     * @throws \LogicException
21
     */
22 83
    public function add($elem): void
23
    {
24 83
        if (!$elem instanceof StubInterface) {
25 1
            throw new InvalidArgumentException(
26 1
                sprintf(
27 1
                    'Element must be an instance of "%s", "%s" given',
28 1
                    StubInterface::class,
29 1
                    \gettype($elem)
30
                )
31
            );
32
        }
33
34 82
        parent::add($elem);
35
    }
36
}
37