Completed
Pull Request — master (#7)
by Ondrej
05:55
created

ImmutableSet::remove()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 10
Ratio 100 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 10
loc 10
rs 9.4285
c 0
b 0
f 0
ccs 6
cts 6
cp 1
cc 2
eloc 6
nc 2
nop 1
crap 2
1
<?php
2
namespace SpareParts\Enum\Set;
3
4
use SpareParts\Enum\Enum;
5
use SpareParts\Enum\Exception\EnumSetMustContainEnumsException;
6
7
class ImmutableSet implements ISet
8
{
9
    use SetTrait;
10
11
    /**
12
     * @param Enum $enum
13
     * @return self
14
     */
15 3 View Code Duplication
    public function add(Enum $enum)
0 ignored issues
show
Duplication introduced by
This method 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...
16
    {
17 3
        if (!($enum instanceof $this->enumClass)) {
18 1
            throw new EnumSetMustContainEnumsException(sprintf("Expected %s, got %s", $this->enumClass, get_class($enum)));
19
        }
20 2
        $set = $this->set;
21 2
        $set[(string) $enum] = $enum;
22
23 2
        return new ImmutableSet($this->enumClass, $set);
24
    }
25
26
    /**
27
     * @param Enum $enum
28
     * @return self
29
     */
30 5 View Code Duplication
    public function remove(Enum $enum)
0 ignored issues
show
Duplication introduced by
This method 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...
31
    {
32 4
        if (!($enum instanceof $this->enumClass)) {
33 1
            throw new EnumSetMustContainEnumsException(sprintf("Expected %s, got %s", $this->enumClass, get_class($enum)));
34
        }
35 3
        $set = $this->set;
36 5
        unset($set[(string) $enum]);
37
38 3
        return new ImmutableSet($this->enumClass, $set);
39
    }
40
}
41