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

MutableVector::remove()   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 MutableVector extends AbstractMutableCollection
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
        $this->resetKeys();
26
    }
27
28
    /**
29
     * @inheritdoc
30
     */
31
    public function removeKey($key)
32
    {
33
        parent::removeKey($key);
34
        $this->resetKeys();
35
    }
36
37
    /**
38
     * @inheritdoc
39
     */
40
    public function remove($value)
41
    {
42
        parent::remove($value);
43
        $this->resetKeys();
44
    }
45
46
    /**
47
     */
48
    protected function resetKeys()
49
    {
50
        $this->values = array_values($this->values);
51
    }
52
}
53