BridgeProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 10
c 1
b 0
f 0
dl 0
loc 39
ccs 12
cts 12
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 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
 * Bridge Provider
14
 *
15
 * @package Zapheus
16
 * @author  Rougin Gutib <[email protected]>
17
 */
18
class BridgeProvider 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 1
    {
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
        {
53 6
            $slytherin = $item->define($slytherin, $config);
54 2
        }
55
56 6
        return $container->set(self::CONTAINER, $slytherin);
57
    }
58
}
59