Completed
Push — master ( d34afe...c8f7b2 )
by Rougin
01:51
created

BridgeProvider::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
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 Royce 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 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