Completed
Push — master ( 4d43de...d186d6 )
by Joram van den
04:11
created

Ajde_Config::__set()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
class Ajde_Config
4
{
5
    /**
6
     * @var Ajde_Config_Repository
7
     */
8
    private $repository;
9
10
    /**
11
     * TODO
12
     */
13
    public function __construct()
14
    {
15
        $this->repository = new Ajde_Config_Repository(CONFIG_DIR);
16
    }
17
18
    /**
19
     * TODO
20
     *
21
     * @return Config
22
     */
23
    public static function getInstance()
24
    {
25
        static $instance;
26
        return $instance === null ? $instance = new self : $instance;
27
    }
28
29
    /**
30
     * TODO
31
     *
32
     * @param string $param
33
     * @return mixed
34
     * @throws Ajde_Exception
35
     */
36
    public static function get($param)
37
    {
38
        $instance = self::getInstance();
39
40
        if (isset($instance->$param)) {
41
            return $instance->$param;
42
        } else {
43
            throw new Ajde_Exception("Config parameter $param not set", 90004);
44
        }
45
    }
46
47
    /**
48
     * TODO
49
     *
50
     * @param string $param
51
     * @param mixed $value
52
     */
53
    public static function set($param, $value)
54
    {
55
        $instance = self::getInstance();
56
57
        $instance->$param  = $value;
58
    }
59
60
    /**
61
     * TODO
62
     *
63
     * @param string $param
64
     * @return mixed
65
     */
66
    public function __get($param)
67
    {
68
        return $this->repository->$param;
69
    }
70
71
    /**
72
     * TODO
73
     *
74
     * @param string $param
75
     * @param mixed $value
76
     */
77
    public function __set($param, $value)
78
    {
79
        $this->repository->$param = $value;
80
    }
81
82
    /**
83
     * TODO
84
     *
85
     * @param string $param
86
     * @return bool
87
     */
88
    public function __isset($param)
89
    {
90
        return isset($this->repository->$param);
91
    }
92
}
93