Completed
Push — master ( de5c9f...2ef464 )
by Daniel
21s queued 11s
created

ConfigServiceProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 7
c 1
b 0
f 0
dl 0
loc 29
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createConfig() 0 6 1
A register() 0 6 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