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

Set::add()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 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