AbstractCalendarUpdated   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 34
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getCalendar() 0 4 1
A serialize() 0 6 1
A deserialize() 0 7 1
1
<?php
2
3
namespace CultuurNet\UDB3\Offer\Events;
4
5
use CultuurNet\UDB3\Calendar;
6
7
abstract class AbstractCalendarUpdated extends AbstractEvent
8
{
9
    /**
10
     * @var Calendar
11
     */
12
    private $calendar;
13
14
    final public function __construct(string $itemId, Calendar $calendar)
15
    {
16
        parent::__construct($itemId);
17
18
        $this->calendar = $calendar;
19
    }
20
21
    public function getCalendar(): Calendar
22
    {
23
        return $this->calendar;
24
    }
25
26
    public function serialize(): array
27
    {
28
        return parent::serialize() + [
29
            'calendar' => $this->calendar->serialize(),
30
        ];
31
    }
32
33
    public static function deserialize(array $data): AbstractCalendarUpdated
34
    {
35
        return new static(
36
            $data['item_id'],
37
            Calendar::deserialize($data['calendar'])
38
        );
39
    }
40
}
41