Completed
Push — master ( dad334...685d59 )
by Alberto
02:51
created

StubSet::add()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 8
cts 8
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 8
nc 2
nop 1
crap 2
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
final class StubSet extends Set
14
{
15
    /**
16
     * @param Stub $elem
17
     * @return void
18
     *
19
     * @throws InvalidArgumentException
20
     */
21 12
    public function add($elem)
22
    {
23 12
        if (!$elem instanceof Stub) {
24 2
            throw new InvalidArgumentException(
25 2
                sprintf(
26 2
                    'The first parameter must be an instance of %s, %s given',
27 2
                    Stub::class,
28 2
                    gettype($elem)
29
                )
30
            );
31
        }
32
33 10
        parent::add($elem);
34
    }
35
}
36