Completed
Push — master ( 3fde7a...7bfc6c )
by Joram van den
03:44
created

Ajde_Config::__get()   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 1
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
        if ($this->repository->get("security.secret") === 'RANDOMSTRING') {
18
            Ajde_Dump::warn('Using unsafe secret: your app is insecure. See class Config_Application');
19
        }
20
    }
21
22
    /**
23
     * TODO
24
     *
25
     * @return Config
26
     */
27
    public static function getInstance()
28
    {
29
        static $instance;
30
31
        return $instance === null ? $instance = new self : $instance;
32
    }
33
34
    /**
35
     * TODO
36
     *
37
     * @param string $param
38
     * @return mixed
39
     * @throws Ajde_Exception
40
     */
41
    public static function get($param)
42
    {
43
        $instance = self::getInstance();
44
45
        return $instance->repository->get($param);
46
    }
47
48
    /**
49
     * TODO
50
     *
51
     * @param string $param
52
     * @param mixed  $value
53
     */
54
    public static function set($param, $value)
55
    {
56
        $instance = self::getInstance();
57
58
        $instance->repository->set($param, $value);
59
    }
60
}
61