Completed
Push — spike ( 2414ba )
by Akihito
06:46
created

AspectBind   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 30%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 30
ccs 3
cts 10
cp 0.3
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A inject() 0 14 4
1
<?php
2
3
declare(strict_types=1);
4
/**
5
 * This file is part of the Ray.Di package.
6
 *
7
 * @license http://opensource.org/licenses/MIT MIT
8
 */
9
namespace Ray\Di;
10
11
use Ray\Aop\Bind as AopBind;
12
13
final class AspectBind
14
{
15
    /**
16
     * @var AopBind
17
     */
18
    private $bind;
19
20 1
    public function __construct(AopBind $bind)
21
    {
22 1
        $this->bind = $bind;
23 1
    }
24
25
    /**
26
     * Instantiate interceptors
27
     */
28
    public function inject(Container $container) : array
29
    {
30
        $bindings = $this->bind->getBindings();
31
        foreach ($bindings as &$interceptors) {
32
            /* @var string[] $interceptors */
33
            foreach ($interceptors as &$interceptor) {
34
                if (\is_string($interceptor)) {
35
                    $interceptor = $container->getInstance($interceptor, Name::ANY);
36
                }
37
            }
38
        }
39
40
        return $bindings;
41
    }
42
}
43