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

AspectBind::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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