Completed
Pull Request — master (#4)
by Alberto
02:58
created

StubSet   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 37.5%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 24
ccs 3
cts 8
cp 0.375
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A add() 0 14 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 object|\PhpCollection\scalar $elem
17
     * @return void
18
     *
19
     * @throws InvalidArgumentException
20
     */
21 8
    public function add($elem)
22
    {
23 8
        if (!$elem instanceof Stub) {
24
            throw new InvalidArgumentException(
25
                sprintf(
26
                    'The first parameter must be an instance of %s but of type %s given',
27
                    Stub::class,
28
                    gettype($elem)
29
                )
30
            );
31
        }
32
33 8
        parent::add($elem);
34
    }
35
36
}
37