ScheduleBuilderKernelPass   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 87.5%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 8
c 1
b 0
f 0
dl 0
loc 17
ccs 7
cts 8
cp 0.875
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 15 4
1
<?php
2
3
namespace Zenstruck\ScheduleBundle\DependencyInjection\Compiler;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Zenstruck\ScheduleBundle\Schedule\ScheduleBuilder;
8
9
/**
10
 * @author Kevin Bond <[email protected]>
11
 */
12
final class ScheduleBuilderKernelPass implements CompilerPassInterface
13
{
14 3
    public function process(ContainerBuilder $container): void
15
    {
16 3
        if (!$container->hasDefinition('kernel')) {
17
            return;
18
        }
19
20 3
        $kernel = $container->getDefinition('kernel');
21
22 3
        if (null === $class = $kernel->getClass()) {
23 1
            return;
24
        }
25
26 2
        /** @var class-string $class */
27 1
        if ((new \ReflectionClass($class))->implementsInterface(ScheduleBuilder::class)) {
28
            $kernel->addTag('schedule.builder');
29 2
        }
30
    }
31
}
32