AbstractTypeUpdated::getType()   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\Offer\Events;
4
5
use CultuurNet\UDB3\Event\EventType;
6
7
abstract class AbstractTypeUpdated extends AbstractEvent
8
{
9
    /**
10
     * @var EventType
11
     */
12
    protected $type;
13
14
    final public function __construct(string $itemId, EventType $type)
15
    {
16
        parent::__construct($itemId);
17
        $this->type = $type;
18
    }
19
20
    public function getType(): EventType
21
    {
22
        return $this->type;
23
    }
24
25
    public function serialize(): array
26
    {
27
        return parent::serialize() + [
28
            'type' => $this->type->serialize(),
29
        ];
30
    }
31
32
    public static function deserialize(array $data): AbstractTypeUpdated
33
    {
34
        return new static($data['item_id'], EventType::deserialize($data['type']));
35
    }
36
}
37