1 | <?php |
||
6 | class Config |
||
7 | { |
||
8 | /** |
||
9 | * Loaded Configuration Items |
||
10 | * |
||
11 | * @var array |
||
12 | */ |
||
13 | protected $configuration = []; |
||
14 | |||
15 | /** |
||
16 | * Path to Configuration Folder |
||
17 | * |
||
18 | * @var string |
||
19 | */ |
||
20 | protected $path; |
||
21 | |||
22 | /** |
||
23 | * Configuration file extension |
||
24 | */ |
||
25 | const CONFIG_FILE_EXTENSION = ".php"; |
||
26 | |||
27 | /** |
||
28 | * Config constructor. |
||
29 | * |
||
30 | * @param $configFolderPath |
||
31 | */ |
||
32 | 27 | public function __construct($configFolderPath = null) |
|
33 | { |
||
34 | 27 | if (is_null($configFolderPath)) { |
|
35 | 2 | $configFolderPath = APP_PATH . DIRECTORY_SEPARATOR . 'Config'; |
|
36 | } |
||
37 | |||
38 | 27 | $this->setPath($configFolderPath); |
|
39 | 27 | } |
|
40 | |||
41 | /** |
||
42 | * Sets the configuration folder path |
||
43 | * |
||
44 | * @param $path |
||
45 | */ |
||
46 | 27 | protected function setPath($path) |
|
50 | |||
51 | /** |
||
52 | * Loads a configuration file in to memory |
||
53 | * |
||
54 | * @param $key |
||
55 | * @throws ConfigException when file is missing |
||
56 | */ |
||
57 | 26 | protected function loadConfigFile(string $key) |
|
69 | |||
70 | /** |
||
71 | * Get Configuration Item |
||
72 | * |
||
73 | * @param $key |
||
74 | * |
||
75 | * @return \stdClass |
||
76 | * @throws ConfigException when config file not found |
||
77 | */ |
||
78 | 27 | public function get(string $key) |
|
88 | |||
89 | /** |
||
90 | * @param string $key |
||
91 | * @param $value mixed array|string |
||
92 | */ |
||
93 | 1 | public function set(string $key, $value) |
|
98 | } |
||
99 |