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

Config   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 11
Bugs 2 Features 0
Metric Value
wmc 7
c 11
b 2
f 0
lcom 1
cbo 2
dl 0
loc 66
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getInstance() 0 5 2
A get() 0 10 2
A __get() 0 4 1
A __isset() 0 4 1
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