Test Failed
Pull Request — master (#1190)
by Aleksei
15:08
created

InjectorMethodResolver::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 0
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 2
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
    public function __construct(
21
        private readonly BinderInterface $binder,
22
        private readonly InvokerInterface $invoker,
23
    ) {}
24
25
    public function resolve(object $attribute, object $service, \ReflectionMethod $method): void
26
    {
27
        $this->binder->bind(
28
            $attribute->alias,
29
            new Injectable($this->invoker->invoke($method->getClosure($service))),
30
        );
31
    }
32
}
33