Passed
Pull Request — master (#58)
by Dmitriy
08:59 queued 06:34
created

LazyDefinitionDecorator::resolve()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1.037

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
nc 1
nop 1
dl 0
loc 8
ccs 4
cts 6
cp 0.6667
crap 1.037
rs 10
c 2
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Definitions;
6
7
use ProxyManager\Factory\LazyLoadingValueHolderFactory;
8
use Psr\Container\ContainerInterface;
9
use Yiisoft\Definitions\Contract\DefinitionInterface;
10
use Yiisoft\Di\Helpers\DefinitionNormalizer;
0 ignored issues
show
Bug introduced by
The type Yiisoft\Di\Helpers\DefinitionNormalizer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
12
final class LazyDefinitionDecorator implements DefinitionInterface
13
{
14 3
    public function __construct(
15
        private LazyLoadingValueHolderFactory $factory,
16
        private mixed $definition,
17
        private string $objectClass,
18
    ) {
19
    }
20
21 3
    public function resolve(ContainerInterface $container): mixed
22
    {
23 3
        return $this->factory->createProxy(
24 3
            $this->objectClass,
25 3
            function (&$wrappedObject) use ($container) {
26
                $definition = DefinitionNormalizer::normalize($this->definition, $this->objectClass);
27
28
                $wrappedObject = $definition->resolve($container);
29
            }
30
        );
31
    }
32
}
33