1 | <?php |
||
17 | class Config implements IConfig |
||
18 | { |
||
19 | |||
20 | protected $path; |
||
21 | protected $env; |
||
22 | protected $settings; |
||
23 | |||
24 | /** |
||
25 | * instanciate |
||
26 | * |
||
27 | * @param string $env |
||
28 | */ |
||
29 | 10 | public function __construct(string $env, string $path) |
|
36 | |||
37 | /** |
||
38 | * set config environment |
||
39 | * |
||
40 | * @param string $env |
||
41 | * @return Config |
||
42 | */ |
||
43 | 10 | public function setEnv(string $env = self::ENV_DEV): Config |
|
48 | |||
49 | /** |
||
50 | * returns env |
||
51 | * |
||
52 | * @return string |
||
53 | */ |
||
54 | 1 | public function getEnv(): string |
|
58 | |||
59 | /** |
||
60 | * set config path |
||
61 | * |
||
62 | * @param string $path |
||
63 | * @return Config |
||
64 | */ |
||
65 | 2 | public function setPath(string $path): Config |
|
70 | |||
71 | /** |
||
72 | * returns config path |
||
73 | * |
||
74 | * @return string |
||
75 | */ |
||
76 | 1 | public function getPath(): string |
|
80 | |||
81 | /** |
||
82 | * return config array for a main entry key |
||
83 | * |
||
84 | * @param string $key |
||
85 | * @return array |
||
86 | */ |
||
87 | 1 | public function getSettings(string $key = ''): array |
|
91 | |||
92 | /** |
||
93 | * return true if config main entry for a key exists |
||
94 | * |
||
95 | * @param string $key |
||
96 | * @return boolean |
||
97 | */ |
||
98 | 1 | public function hasEntry(string $key): bool |
|
102 | |||
103 | /** |
||
104 | * load config for a given env |
||
105 | * |
||
106 | * @return Config |
||
107 | */ |
||
108 | 10 | public function load(): Config |
|
123 | |||
124 | /** |
||
125 | * getFilename |
||
126 | * |
||
127 | * @return string |
||
128 | */ |
||
129 | 1 | protected function getFilename(): string |
|
133 | |||
134 | /** |
||
135 | * check |
||
136 | * |
||
137 | * @param string $filename |
||
138 | * @return boolean |
||
139 | */ |
||
140 | 1 | protected function check($filename): bool |
|
145 | |||
146 | /** |
||
147 | * getAllowedEnv |
||
148 | * |
||
149 | * @return array |
||
150 | */ |
||
151 | 1 | protected function getAllowedEnv(): array |
|
158 | } |
||
159 |