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

Vector   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A set() 0 5 1
A remove() 0 5 1
A removeKey() 0 5 1
A resetKeys() 0 4 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