Completed
Push — master ( 7e3d04...dc7866 )
by Changwan
06:39
created

Assign::onBindMethod()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 4
dl 0
loc 10
ccs 4
cts 4
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
1
<?php
2
namespace Wandu\DI\Annotations;
3
4
use Doctrine\Common\Annotations\Annotation\Required;
5
use Doctrine\Common\Annotations\Annotation\Target;
6
use ReflectionClass;
7
use ReflectionMethod;
8
use Wandu\DI\Descriptor;
9
use Wandu\DI\ContainerInterface;
10
use Wandu\DI\Contracts\MethodDecoratorInterface;
11
12
/**
13
 * @Annotation
14
 * @Target({"METHOD"})
15
 */
16
class Assign implements MethodDecoratorInterface
17
{
18
    /** @Required @var string */
19
    public $target;
20
21
    /** @Required @var string */
22
    public $name;
23
24
    /**
25
     * {@inheritdoc}
26
     */
27 1
    public function onBindMethod(
28
        ReflectionMethod $reflMethod,
29
        ReflectionClass $reflClass,
30
        Descriptor $desc,
31
        ContainerInterface $container
32
    ) {
33 1
        $desc->assign([
34 1
            $this->target => $container->get($this->name),
35
        ]);
36 1
    }
37
}
38