ConfigProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 21
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 18 3
1
<?php
2
3
namespace XHGui\ServiceProvider;
4
5
use Pimple\Container;
6
use Pimple\ServiceProviderInterface;
7
use XHGui\Config;
8
9
class ConfigProvider implements ServiceProviderInterface
10
{
11
    public function register(Container $app): void
12
    {
13
        $app['config'] = static function ($app) {
14
            // @deprecated
15
            // define XHGUI_ROOT_DIR constant, config files may use it
16
            if (!defined('XHGUI_ROOT_DIR')) {
17
                define('XHGUI_ROOT_DIR', $app['app.dir']);
18
            }
19
20
            Config::load($app['app.config_dir'] . '/config.default.php');
21
22
            if (file_exists($app['app.config_dir'] . '/config.php')) {
23
                Config::load($app['app.config_dir'] . '/config.php');
24
            }
25
26
            return Config::all();
27
        };
28
    }
29
}
30