Completed
Pull Request — master (#112)
by
unknown
02:44
created

ConfigAbstract::configure()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 7
rs 9.4285
cc 2
eloc 3
nc 2
nop 1
1
<?php
2
namespace SEOstats\Config;
3
4
abstract class ConfigAbstract
5
{
6
    protected static $config = [];
7
8
    public static function configure($config)
9
    {
10
        // Update only existed
11
        foreach ($config as $key => $value) {
12
            static::set($key, $config[$key]);
13
        }
14
    }
15
16
    public static function set($name, $value)
17
    {
18
        if (isset(static::$config[$name])) {
19
            static::$config[$name] = $value;
20
        }
21
    }
22
23
    public static function get($name)
24
    {
25
        if (!isset(static::$config[$name])) {
26
            throw new \Exception("Value for $name does not exist");
27
        }
28
        return static::$config[$name];
29
    }
30
}
31