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

ConfigAbstract   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 6
c 1
b 0
f 1
lcom 1
cbo 0
dl 0
loc 27
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 7 2
A set() 0 6 2
A get() 0 7 2
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