Passed
Pull Request — master (#39)
by Daniel
03:37
created

ConfigServiceProvider::createConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
c 0
b 0
f 0
dl 0
loc 6
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Jellyfish\Config;
6
7
use Pimple\Container;
8
use Pimple\ServiceProviderInterface;
9
10
class ConfigServiceProvider implements ServiceProviderInterface
11
{
12
    /**
13
     * @param \Pimple\Container $container
14
     *
15
     * @return void
16
     */
17
    public function register(Container $container): void
18
    {
19
        $this->registerConfigFacade($container);
20
    }
21
22
    /**
23
     * @param \Pimple\Container $container
24
     *
25
     * @return \Jellyfish\Config\ConfigServiceProvider
26
     */
27
    public function registerConfigFacade(Container $container): ConfigServiceProvider
28
    {
29
        $container->offsetSet(ConfigConstants::FACADE, static function (Container $container) {
30
            $appDir = $container->offsetGet('app_dir');
31
            $environment = $container->offsetGet('environment');
32
33
            return new ConfigFacade(
34
                new ConfigFactory($appDir, $environment)
35
            );
36
        });
37
38
        return $this;
39
    }
40
}
41