ScheduleTimezoneSubscriber   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 5
c 0
b 0
f 0
dl 0
loc 18
ccs 8
cts 8
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getSubscribedEvents() 0 3 1
A setTimezone() 0 3 1
A __construct() 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
8
/**
9
 * @author Kevin Bond <[email protected]>
10
 */
11
final class ScheduleTimezoneSubscriber implements EventSubscriberInterface
12
{
13
    /** @var string */
14
    private $timezone;
15 1
16
    public function __construct(string $timezone)
17 1
    {
18 1
        $this->timezone = $timezone;
19
    }
20 1
21
    public static function getSubscribedEvents(): array
22 1
    {
23
        return [BuildScheduleEvent::class => 'setTimezone'];
24
    }
25 1
26
    public function setTimezone(BuildScheduleEvent $event): void
27 1
    {
28 1
        $event->getSchedule()->timezone($this->timezone);
29
    }
30
}
31