BridgeProvider::register()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 14
ccs 9
cts 9
cp 1
rs 10
cc 2
nc 2
nop 1
crap 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