Completed
Push — master ( de5c9f...2ef464 )
by Daniel
21s queued 11s
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 $pimple
14
     *
15
     * @return void
16
     */
17
    public function register(Container $pimple): void
18
    {
19
        $self = $this;
20
21
        $pimple->offsetSet('config', static function (Container $container) use ($self) {
22
            return $self->createConfig($container);
23
        });
24
    }
25
26
    /**
27
     * @param \Pimple\Container $container
28
     *
29
     * @return \Jellyfish\Config\ConfigInterface
30
     *
31
     * @throws \Exception
32
     */
33
    protected function createConfig(Container $container): ConfigInterface
34
    {
35
        $appDir = $container->offsetGet('app_dir');
36
        $environment = $container->offsetGet('environment');
37
38
        return new Config($appDir, $environment);
39
    }
40
}
41