Completed
Push — master ( bdaaad...4f4372 )
by personal
06:57 queued 04:36
created

Config::all()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Hal\Application\Config;
3
4
class Config
5
{
6
7
    /**
8
     * @var array
9
     */
10
    private $bag = [];
11
12
    /**
13
     * @param $key
14
     * @param $value
15
     * @return $this
16
     */
17
    public function set($key, $value)
18
    {
19
        $this->bag[$key] = $value;
20
        return $this;
21
    }
22
23
    /**
24
     * @param $key
25
     * @return bool
26
     */
27
    public function has($key)
28
    {
29
        return isset($this->bag[$key]);
30
    }
31
32
    /**
33
     * @param $key
34
     * @return null
35
     */
36
    public function get($key)
37
    {
38
        return $this->has($key) ? $this->bag[$key] : null;
39
    }
40
41
    /**
42
     * @return array
43
     */
44
    public function all()
45
    {
46
        return $this->bag;
47
    }
48
49
    /**
50
     * @param array $array
51
     * @return $this
52
     */
53
    public function fromArray(array $array)
54
    {
55
        foreach ($array as $key => $value) {
56
            $this->set($key, $value);
57
        }
58
        return $this;
59
    }
60
}
61