Config::getInstance()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace cvweiss\projectbase;
4
5
class Config
6
{
7
    private static $instance = null;
8
9
    public static function getInstance()
10
    {
11
        self::$instance = self::$instance ?? new Config();
12
        return self::$instance;
13
    }
14
15
    private $settings = ['debug' => true];
16
17
    public function get(string $key, $default = null)
18
    {
19
        return $this->settings[$key] ?? $default;
20
    }
21
22
    public function getAll():array
23
    {
24
        return $this->settings;
25
    }
26
27
    public function set(string $key, $value)
28
    {
29
        $this->settings[$key] = $value;
30
    }
31
32
    public function setAll(array $keys)
33
    {
34
        foreach ($keys as $key=>$value) {
35
            $this->set($key, $value);
36
        }
37
    }
38
}
39