Completed
Push — master ( 5a5aff...6d6efd )
by Joram van den
04:02
created

Config::__construct()   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 0
1
<?php
2
3
class 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
     * @return mixed
52
     */
53
    public function __get($param)
54
    {
55
        return $this->repository->$param;
56
    }
57
58
    /**
59
     * TODO
60
     *
61
     * @param string $param
62
     * @return bool
63
     */
64
    public function __isset($param)
65
    {
66
        return isset($this->repository->$param);
67
    }
68
}
69