Passed
Push — master ( 37e0c1...a3c101 )
by Oleg
05:35
created

ArrayCollection::set()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 2
1
<?php
2
3
namespace Doctrs\StoredProcedureBundle\Utils;
4
5
use ArrayIterator;
6
use Closure;
7
use Doctrine\Common\Collections\Expr\ClosureExpressionVisitor;
0 ignored issues
show
Bug introduced by
The type Doctrine\Common\Collecti...losureExpressionVisitor was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
9
class ArrayCollection
10
{
11
    /**
12
     * @var array
13
     */
14
    private $elements;
15
16
    /**
17
     * ArrayCollection constructor.
18
     *
19
     * @param array $elements
20
     */
21
    public function __construct(array $elements = [])
22
    {
23
        $this->elements = $elements;
24
    }
25
26
    /**
27
     * @param $key
28
     *
29
     * @return mixed|null
30
     */
31
    public function remove($key)
32
    {
33
        if (!isset($this->elements[$key]) && !array_key_exists($key, $this->elements)) {
34
            return null;
35
        }
36
37
        $removed = $this->elements[$key];
38
        unset($this->elements[$key]);
39
40
        return $removed;
41
    }
42
43
    /**
44
     * @param $element
45
     *
46
     * @return bool
47
     */
48
    public function removeElement($element)
49
    {
50
        $key = array_search($element, $this->elements, true);
51
52
        if ($key === false) {
53
            return false;
54
        }
55
56
        unset($this->elements[$key]);
57
58
        return true;
59
    }
60
61
    /**
62
     * @param $key
63
     *
64
     * @return mixed|null
65
     */
66
    public function get($key)
67
    {
68
        return $this->elements[$key] ?? null;
69
    }
70
71
    /**
72
     * @param $key
73
     * @param $value
74
     */
75
    public function set($key, $value)
76
    {
77
        $this->elements[$key] = $value;
78
    }
79
}
80