Completed
Push — master ( 554965...db72da )
by Joram van den
03:50
created

Ajde_Config::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 2
eloc 4
nc 2
nop 0
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") === '_RANDOM_12_16_OR_32_CHAR_STRING_') {
18
            Ajde_Dump::warn('Using unsafe secret: your app is insecure. See security.json');
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
    /**
62
     * TODO
63
     *
64
     * @return Ajde_Config_Repository
65
     */
66
    public static function repository()
67
    {
68
        $instance = self::getInstance();
69
70
        return $instance->repository;
71
    }
72
}
73