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

InjectorMethodResolver::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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