Completed
Push — master ( f55937...6ea988 )
by Eric
06:30
created

MutableSet   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 6
c 2
b 0
f 1
lcom 1
cbo 1
dl 0
loc 51
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A contains() 0 4 1
A get() 0 5 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 contains($value)
22
    {
23
        return $this->containsKey($value);
24
    }
25
26
    /**
27
     * @inheritdoc
28
     */
29
    public function get($key)
30
    {
31
        $this->assertContainsKey($key);
32
        return $key;
33
    }
34
35
    /**
36
     * @inheritdoc
37
     */
38
    public function add($value)
39
    {
40
        $this->values[$value] = true;
41
    }
42
43
    /**
44
     * @inheritdoc
45
     */
46
    public function set($key, $value)
47
    {
48
        $this->add($value);
49
    }
50
51
    /**
52
     * @inheritdoc
53
     */
54
    public function remove($value)
55
    {
56
        $this->removeKey($value);
57
    }
58
}
59