@@ -16,21 +16,21 @@ class Config
1616 * @var array
1717 */
1818 protected static $ context = [
19- 'app ' => ['down ' => false , 'instance ' => null ],
19+ 'app ' => null ,
20+ 'app.down ' => false ,
2021 'debug ' => true ,
21- 'eien ' => ['enabled ' => true ],
22- 'http ' => ['version ' => '1.1 ' ],
23- 'log ' => [
24- 'writer ' => null ,
25- 'level ' => null ,
26- 'enabled ' => false ,
27- 'dir ' => __DIR__ . '/../../../../storage/logs/ ' ,
28- 'file ' => 'log.txt ' ,
29- 'open ' => true ,
30- ],
22+ 'eien.enabled ' => true ,
23+ 'http.version ' => '1.1 ' ,
24+ 'log.writer ' => null ,
25+ 'log.level ' => null ,
26+ 'log.enabled ' => false ,
27+ 'log.dir ' => __DIR__ . '/../../../../storage/logs/ ' ,
28+ 'log.file ' => 'log.txt ' ,
29+ 'log.open ' => true ,
3130 'mode ' => 'development ' ,
3231 'scripts ' => [],
33- 'views ' => ['path ' => null , 'cachePath ' => null ],
32+ 'views.path ' => null ,
33+ 'views.cachePath ' => null ,
3434 ];
3535
3636 /**
@@ -42,18 +42,9 @@ class Config
4242 public static function set ($ item , $ value = null )
4343 {
4444 if (\is_string ($ item )) {
45- if (!\strpos ($ item , '. ' )) {
46- static ::$ context [$ item ] = $ value ;
47- } else {
48- static ::$ context = \array_merge (
49- static ::$ context ,
50- static ::mapContext ($ item , $ value )
51- );
52- }
45+ static ::$ context [$ item ] = $ value ;
5346 } else {
54- foreach ($ item as $ k => $ v ) {
55- static ::set ($ k , $ v );
56- }
47+ static ::$ context = \array_merge (static ::$ context , $ item );
5748 }
5849 }
5950
@@ -82,7 +73,7 @@ public static function get($item = null)
8273 return static ::$ context ;
8374 }
8475
85- $ value = \ Leaf \Anchor:: deepGetDot ( static ::$ context, $ item) ;
76+ $ value = static ::$ context[ $ item] ?? null ;
8677
8778 return static ::isInvokable ($ value ) ? $ value (static ::$ context ) : $ value ;
8879 }
@@ -198,33 +189,23 @@ public static function reset()
198189 {
199190 static ::$ context = [
200191 'app ' => static ::$ context ['app ' ],
192+ 'app.down ' => static ::$ context ['app.down ' ],
201193 'debug ' => static ::$ context ['debug ' ],
202- 'eien ' => static ::$ context ['eien ' ],
203- 'http ' => static ::$ context ['http ' ],
204- 'log ' => static ::$ context ['log ' ],
194+ 'eien.enabled ' => static ::$ context ['eien.enabled ' ],
195+ 'http.version ' => static ::$ context ['http.version ' ],
196+ 'log.writer ' => static ::$ context ['log.writer ' ],
197+ 'log.level ' => static ::$ context ['log.level ' ],
198+ 'log.enabled ' => static ::$ context ['log.enabled ' ],
199+ 'log.dir ' => static ::$ context ['log.dir ' ],
200+ 'log.file ' => static ::$ context ['log.file ' ],
201+ 'log.open ' => static ::$ context ['log.open ' ],
205202 'mode ' => static ::$ context ['mode ' ],
206203 'scripts ' => [],
207- 'views ' => static ::$ context ['views ' ],
204+ 'views.path ' => static ::$ context ['views.path ' ],
205+ 'views.cachePath ' => static ::$ context ['views.cachePath ' ],
208206 ];
209207 }
210208
211- /**
212- * Map nested config to their parents recursively
213- */
214- protected static function mapContext (string $ item , $ value = null )
215- {
216- $ config = \explode ('. ' , $ item );
217-
218- if (\count ($ config ) > 2 ) {
219- \trigger_error ('Nested config can \'t be more than 1 level deep ' );
220- }
221-
222- return [$ config [0 ] => \array_merge (
223- static ::$ context [$ config [0 ]] ?? [],
224- [$ config [1 ] => $ value ]
225- )];
226- }
227-
228209 protected static function getDiIndex ($ class )
229210 {
230211 $ fullName = \explode ("\\" , \strtolower (\get_class ($ class )));
0 commit comments