Completed
Push — master ( fa6370...25cc22 )
by Eric
06:29
created

Set   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 42
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A add() 0 4 1
A set() 0 4 1
A contains() 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 Set extends AbstractCollection
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
     * @param mixed $value
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 contains($value)
38
    {
39
        return parent::containsKey($value);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (containsKey() instead of contains()). Are you sure this is correct? If so, you might want to change this to $this->containsKey().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
40
    }
41
42
    /**
43
     * @inheritdoc
44
     */
45
    public function remove($value)
46
    {
47
        parent::removeKey($value);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (removeKey() instead of remove()). Are you sure this is correct? If so, you might want to change this to $this->removeKey().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
48
    }
49
}
50