BridgeProvider::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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