ArrayCollection::add()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 1
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