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

Vector::removeKey()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace Oqq\Minc\Common\Collection;
4
5
/**
6
 * @author Eric Braun <[email protected]>
7
 */
8
class Vector extends AbstractCollection
9
{
10
    /**
11
     * @param array ...$values
12
     */
13
    public function __construct(...$values)
14
    {
15
        parent::__construct($values);
16
    }
17
18
    /**
19
     * @inheritdoc
20
     */
21
    public function set($key, $value)
22
    {
23
        $this->assertContainsKey($key);
24
        parent::set($key, $value);
25
    }
26
27
    /**
28
     * @inheritdoc
29
     */
30
    public function remove($value)
31
    {
32
        parent::remove($value);
33
        $this->resetKeys();
34
    }
35
36
    /**
37
     * @inheritdoc
38
     */
39
    public function removeKey($key)
40
    {
41
        parent::removeKey($key);
42
        $this->resetKeys();
43
    }
44
45
    /**
46
     */
47
    protected function resetKeys()
48
    {
49
        $this->values = array_values($this->values);
50
    }
51
}
52