Completed
Push — master ( c3be57...f55937 )
by Eric
09:52
created

MutableSet   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 34
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A add() 0 4 1
A set() 0 4 1
A remove() 0 4 1
1
<?php
2
3
namespace Oqq\Minc\Common\Collection;
4
5
/**
6
 * @author Eric Braun <[email protected]>
7
 */
8
class MutableSet extends AbstractMutableCollection
9
{
10
    /**
11
     * @param array ...$values
12
     */
13
    public function __construct(...$values)
14
    {
15
        parent::__construct(array_fill_keys($values, true));
16
    }
17
18
    /**
19
     * @inheritdoc
20
     */
21
    public function add($value)
22
    {
23
        $this->values[$value] = true;
24
    }
25
26
    /**
27
     * @inheritdoc
28
     */
29
    public function set($key, $value)
30
    {
31
        $this->add($value);
32
    }
33
34
    /**
35
     * @inheritdoc
36
     */
37
    public function remove($value)
38
    {
39
        $this->removeKey($value);
40
    }
41
}
42