Passed
Push — master ( 751812...ad3fb0 )
by Kevin
02:24
created

ScheduleExtensionSubscriber   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
dl 0
loc 21
rs 10
c 0
b 0
f 0
eloc 6
ccs 8
cts 8
cp 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A addExtensions() 0 4 2
A __construct() 0 3 1
A getSubscribedEvents() 0 3 1
1
<?php
2
3
namespace Zenstruck\ScheduleBundle\EventListener;
4
5
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
6
use Zenstruck\ScheduleBundle\Event\BuildScheduleEvent;
7
use Zenstruck\ScheduleBundle\Schedule\Extension;
8
9
/**
10
 * @author Kevin Bond <[email protected]>
11
 */
12
final class ScheduleExtensionSubscriber implements EventSubscriberInterface
13
{
14
    private $extensions;
15
16
    /**
17
     * @param Extension[] $extensions
18
     */
19 1
    public function __construct(iterable $extensions)
20
    {
21 1
        $this->extensions = $extensions;
22 1
    }
23
24 1
    public static function getSubscribedEvents(): array
25
    {
26 1
        return [BuildScheduleEvent::class => 'addExtensions'];
27
    }
28
29 1
    public function addExtensions(BuildScheduleEvent $event): void
30
    {
31 1
        foreach ($this->extensions as $extension) {
32 1
            $event->getSchedule()->addExtension($extension);
33
        }
34 1
    }
35
}
36