Passed
Push — 2.x ( 6f8018...f6f39e )
by Akihito
02:47 queued 15s
created

CompileNullObject::__invoke()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ray\Di;
6
7
/**
8
 * Convert NullObjectDependency to Dependency
9
 */
10
final class CompileNullObject
11
{
12
    public function __invoke(Container $container, string $scriptDir): void
13
    {
14
        $container->map(static function (DependencyInterface $dependency) use ($scriptDir) {
15
            if ($dependency instanceof NullObjectDependency) {
16
                return $dependency->toNull($scriptDir);
17
            }
18
19
            return $dependency;
20
        });
21
    }
22
}
23