MajorInfoUpdated::getTitle()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace CultuurNet\UDB3\Place\Events;
4
5
use CultuurNet\UDB3\Address\Address;
6
use CultuurNet\UDB3\Calendar;
7
use CultuurNet\UDB3\Event\EventType;
8
use CultuurNet\UDB3\Place\PlaceEvent;
9
use CultuurNet\UDB3\Theme;
10
use CultuurNet\UDB3\Title;
11
12
final class MajorInfoUpdated extends PlaceEvent
13
{
14
    /**
15
     * @var Title
16
     */
17
    private $title;
18
19
    /**
20
     * @var EventType
21
     */
22
    private $eventType;
23
24
    /**
25
     * @var Theme|null
26
     */
27
    private $theme;
28
29
    /**
30
     * @var Address
31
     */
32
    private $address;
33
34
    /**
35
     * @var Calendar
36
     */
37
    private $calendar;
38
39
    final public function __construct(
40
        string $placeId,
41
        Title $title,
42
        EventType $eventType,
43
        Address $address,
44
        Calendar $calendar,
45
        ?Theme $theme = null
46
    ) {
47
        parent::__construct($placeId);
48
49
        $this->title = $title;
50
        $this->eventType = $eventType;
51
        $this->address = $address;
52
        $this->calendar = $calendar;
53
        $this->theme = $theme;
54
    }
55
56
    public function getTitle(): Title
57
    {
58
        return $this->title;
59
    }
60
61
    public function getEventType(): EventType
62
    {
63
        return $this->eventType;
64
    }
65
66
    public function getTheme(): ?Theme
67
    {
68
        return $this->theme;
69
    }
70
71
    public function getCalendar(): Calendar
72
    {
73
        return $this->calendar;
74
    }
75
76
    public function getAddress(): Address
77
    {
78
        return $this->address;
79
    }
80
81
    public function serialize(): array
82
    {
83
        $theme = null;
84
        if ($this->getTheme() !== null) {
85
            $theme = $this->getTheme()->serialize();
86
        }
87
        return parent::serialize() + array(
88
            'title' => (string)$this->getTitle(),
89
            'event_type' => $this->getEventType()->serialize(),
90
            'theme' => $theme,
91
            'address' => $this->getAddress()->serialize(),
92
            'calendar' => $this->getCalendar()->serialize(),
93
        );
94
    }
95
96
    public static function deserialize(array $data): MajorInfoUpdated
97
    {
98
        return new static(
99
            $data['place_id'],
100
            new Title($data['title']),
101
            EventType::deserialize($data['event_type']),
102
            Address::deserialize($data['address']),
103
            Calendar::deserialize($data['calendar']),
104
            empty($data['theme']) ? null : Theme::deserialize($data['theme'])
105
        );
106
    }
107
}
108