Completed
Push — drivers ( fe89be...446647 )
by Joe
01:59
created

Container::get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 3
rs 10
1
<?php
2
3
namespace PhpWinTools\WmiScripting\Containers;
4
5
use Illuminate\Support\Arr;
6
7
class Container
8
{
9
    protected $container;
10
11
    public function get($key, $default = null)
12
    {
13
        return Arr::get($this->container, $key, $default);
14
    }
15
16
    public function append($key, $value)
0 ignored issues
show
Unused Code introduced by
The parameter $value is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

16
    public function append($key, /** @scrutinizer ignore-unused */ $value)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
17
    {
18
        if (is_null($this->get($key))) {
19
            //
20
        }
21
    }
22
23
    public function set($key, $value = null)
24
    {
25
        $keys = is_array($key) ? $key : [$key => $value];
26
27
        foreach ($keys as $key => $value) {
0 ignored issues
show
introduced by
$key is overwriting one of the parameters of this function.
Loading history...
28
            Arr::set($this->container, $key, $value);
29
        }
30
31
        return $this;
32
    }
33
34
    public function merge(array $array)
35
    {
36
        foreach (Arr::dot($array) as $key => $value) {
37
            $this->container = Arr::add($this->container, $key, $value);
38
        }
39
40
        return $this;
41
    }
42
}
43