Completed
Push — master ( 53f80b...806b60 )
by Rougin
01:36
created

SlytherinProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
cbo 3
dl 0
loc 40
ccs 12
cts 12
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A register() 0 14 2
1
<?php
2
3
namespace Zapheus\Bridge\Slytherin;
4
5
use Rougin\Slytherin\Container\Container as SlytherinContainer;
6
use Rougin\Slytherin\Integration\Configuration as SlytherinConfig;
7
use Rougin\Slytherin\Integration\IntegrationInterface;
8
use Zapheus\Container\WritableInterface;
9
use Zapheus\Provider\Configuration;
10
use Zapheus\Provider\ProviderInterface;
11
12
/**
13
 * Slytherin Provider
14
 *
15
 * @package Zapheus
16
 * @author  Rougin Royce Gutib <[email protected]>
17
 */
18
class SlytherinProvider implements ProviderInterface
19
{
20
    const CONTAINER = 'Rougin\Slytherin\Container\Container';
21
22
    /**
23
     * @var \Rougin\Slytherin\Integration\IntegrationInterface[]
24
     */
25
    protected $integrations;
26
27
    /**
28
     * Initializes the provider instance.
29
     *
30
     * @param \Rougin\Slytherin\Integration\IntegrationInterface[] $integrations
31
     */
32 6
    public function __construct($integrations)
33
    {
34 6
        $this->integrations = $integrations;
35 6
    }
36
37
    /**
38
     * Registers the bindings in the container.
39
     *
40
     * @param  \Zapheus\Container\WritableInterface $container
41
     * @return \Zapheus\Container\ContainerInterface
42
     */
43 6
    public function register(WritableInterface $container)
44 2
    {
45 6
        $config = $container->get(ProviderInterface::CONFIG);
46
47 6
        $slytherin = new SlytherinContainer;
48
49 6
        $config = new SlytherinConfig($config->all());
50
51 6
        foreach ((array) $this->integrations as $item) {
52 6
            $slytherin = $item->define($slytherin, $config);
53 4
        }
54
55 6
        return $container->set(self::CONTAINER, $slytherin);
56
    }
57
}
58