@@ -43,34 +43,32 @@ public function getConfig($type = null): Config
4343 $ type = isset ($ types [$ type ]) ? $ type : 'ini ' ;
4444
4545 foreach (['app/config/ ' , 'config/ ' , 'apps/config/ ' , 'apps/frontend/config/ ' ] as $ configPath ) {
46- if ('ini ' == $ type && file_exists ($ this ->rootPath . $ configPath . 'config.ini ' )) {
46+ if ('ini ' === $ type && file_exists ($ this ->rootPath . $ configPath . 'config.ini ' )) {
4747 return new ConfigIni ($ this ->rootPath . $ configPath . 'config.ini ' );
48- } else {
49- if (file_exists ($ this ->rootPath . $ configPath . 'config.php ' )) {
50- $ config = include ($ this ->rootPath . $ configPath . 'config.php ' );
51- if (is_array ($ config )) {
52- $ config = new Config ($ config );
53- }
54-
55- return $ config ;
48+ }
49+ if (file_exists ($ this ->rootPath . $ configPath . 'config.php ' )) {
50+ $ config = include ($ this ->rootPath . $ configPath . 'config.php ' );
51+ if (is_array ($ config )) {
52+ $ config = new Config ($ config );
5653 }
54+
55+ return $ config ;
5756 }
5857 }
5958
6059 $ directory = new RecursiveDirectoryIterator ('. ' );
6160 $ iterator = new RecursiveIteratorIterator ($ directory );
6261 foreach ($ iterator as $ f ) {
63- if (preg_match ( ' /\/config\.php$/i ' , $ f ->getPathName ())) {
62+ if (false !== strpos ( $ f ->getPathName (), ' config.php ' )) {
6463 $ config = include $ f ->getPathName ();
6564 if (is_array ($ config )) {
6665 $ config = new Config ($ config );
6766 }
6867
6968 return $ config ;
70- } else {
71- if (preg_match ('/config\.ini$/i ' , $ f ->getPathName ())) {
72- return new ConfigIni ($ f ->getPathName ());
73- }
69+ }
70+ if (false !== strpos ($ f ->getPathName (), 'config.ini ' )) {
71+ return new ConfigIni ($ f ->getPathName ());
7472 }
7573 }
7674
0 commit comments