ArrayCollection   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 35
c 0
b 0
f 0
wmc 4
lcom 1
cbo 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A add() 0 4 1
A remove() 0 6 2
1
<?php
2
3
namespace Saxulum\Accessor\Collection;
4
5
class ArrayCollection implements CollectionInterface
6
{
7
    /**
8
     * @var array
9
     */
10
    protected $array;
11
12
    /**
13
     * @param array $array
14
     */
15
    public function __construct(array &$array)
16
    {
17
        $this->array = &$array;
18
    }
19
20
    /**
21
     * @param  mixed $element
22
     * @return void
23
     */
24
    public function add($element)
25
    {
26
        $this->array[] = $element;
27
    }
28
29
    /**
30
     * @param  mixed $element
31
     * @return void
32
     */
33
    public function remove($element)
34
    {
35
        if (false !== $index = array_search($element, $this->array, true)) {
36
            unset($this->array[$index]);
37
        }
38
    }
39
}
40