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

Assign   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 22
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
wmc 1
lcom 1
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A onBindMethod() 0 10 1
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