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

ScheduleExtensionSubscriber::getSubscribedEvents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
eloc 1
ccs 2
cts 2
cp 1
cc 1
nc 1
nop 0
crap 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