Passed
Push — master ( 477224...3259b8 )
by Aleksei
06:12 queued 18s
created

InjectorMethodResolver   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 4
c 1
b 0
f 0
dl 0
loc 12
ccs 6
cts 6
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A resolve() 0 5 1
A __construct() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Spiral\Boot\BootloadManager\AttributeResolver;
6
7
use Spiral\Boot\Attribute\InjectorMethod;
8
use Spiral\Boot\Bootloader\BootloaderInterface;
9
use Spiral\Boot\BootloadManager\AttributeResolverInterface;
10
use Spiral\Core\BinderInterface;
11
use Spiral\Core\Config\Injectable;
12
use Spiral\Core\InvokerInterface;
13
14
/**
15
 * @internal
16
 * @implements AttributeResolverInterface<InjectorMethod, BootloaderInterface>
17
 */
18
final class InjectorMethodResolver implements AttributeResolverInterface
19
{
20 19
    public function __construct(
21
        private readonly BinderInterface $binder,
22
        private readonly InvokerInterface $invoker,
23 19
    ) {}
24
25 4
    public function resolve(object $attribute, object $service, \ReflectionMethod $method): void
26
    {
27 4
        $this->binder->bind(
28 4
            $attribute->alias,
29 4
            new Injectable($this->invoker->invoke($method->getClosure($service))),
30 4
        );
31
    }
32
}
33