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

SingletonMethodResolver::resolve()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 9
ccs 7
cts 7
cp 1
rs 10
cc 1
nc 1
nop 3
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Spiral\Boot\BootloadManager\AttributeResolver;
6
7
use Spiral\Boot\Attribute\SingletonMethod;
8
use Spiral\Boot\Bootloader\BootloaderInterface;
9
use Spiral\Core\Config\Factory;
10
11
/**
12
 * @internal
13
 * @extends AbstractResolver<SingletonMethod, BootloaderInterface>
14
 */
15
final class SingletonMethodResolver extends AbstractResolver
16
{
17 8
    public function resolve(object $attribute, object $service, \ReflectionMethod $method): void
18
    {
19 8
        $aliases = $this->getAliases($attribute, $method);
20 5
        $closure = new Factory(
21 5
            callable: $method->getClosure($service),
22 5
            singleton: true,
23 5
        );
24
25 5
        $this->bind($aliases, $closure, $this->getScopes($method));
26
    }
27
}
28