Completed
Pull Request — master (#315)
by Elan
01:14
created

Xhgui_Config::shouldRun()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
/**
3
 * Loads and reads config file.
4
 */
5
class Xhgui_Config
6
{
7
    private static $_config = array();
8
9
    /**
10
     * Load a config file, it will replace
11
     * all the currently loaded configuration.
12
     *
13
     * @return void
14
     */
15
    public static function load($file)
16
    {
17
        $config = include($file);
18
        self::$_config = array_merge(self::$_config, $config);
19
    }
20
21
    /**
22
     * Read a config value.
23
     *
24
     * @param string $name The name of the config variable
25
     * @return mixed The value or null.
26
     */
27
    public static function read($name)
28
    {
29
        if (isset(self::$_config[$name])) {
30
            return self::$_config[$name];
31
        }
32
        return null;
33
    }
34
35
    /**
36
     * Get all the configuration options.
37
     *
38
     * @return array
39
     */
40
    public static function all()
41
    {
42
        return self::$_config;
43
    }
44
45
    /**
46
     * Write a config value.
47
     *
48
     * @param string $name The name of the config variable
49
     * @param mixed $value The value of the config variable
50
     * @return void
51
     */
52
    public static function write($name, $value)
53
    {
54
        self::$_config[$name] = $value;
55
    }
56
57
    /**
58
     * Clear out the data stored in the config class.
59
     *
60
     * @return void
61
     */
62
    public static function clear()
63
    {
64
        self::$_config = array();
65
    }
66
}
67