Set   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 10
c 1
b 0
f 0
dl 0
loc 20
ccs 10
cts 10
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 7 2
A remove() 0 7 2
1
<?php
2
namespace SpareParts\Enum\Set;
3
4
use SpareParts\Enum\Enum;
5
use SpareParts\Enum\Exception\EnumSetMustContainEnumsException;
6
7
class Set implements ISet
8
{
9
    use SetTrait;
10
11 3
    public function add(Enum $enum): ISet
12
    {
13 3
        if (!($enum instanceof $this->enumClass)) {
14 1
            throw new EnumSetMustContainEnumsException(sprintf("Expected %s, got %s", $this->enumClass, get_class($enum)));
15
        }
16 2
        $this->set[(string) $enum] = $enum;
17 2
        return $this;
18
    }
19
20 4
    public function remove(Enum $enum): ISet
21
    {
22 4
        if (!($enum instanceof $this->enumClass)) {
23 1
            throw new EnumSetMustContainEnumsException(sprintf("Expected %s, got %s", $this->enumClass, get_class($enum)));
24
        }
25 3
        unset($this->set[(string) $enum]);
26 3
        return $this;
27
    }
28
}
29