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

Ajde_Config   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 7
c 4
b 0
f 0
lcom 1
cbo 3
dl 0
loc 70
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A getInstance() 0 6 2
A get() 0 6 1
A set() 0 6 1
A repository() 0 6 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") === '_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