AbstractLabelEvent::getLabelId()   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\Role\Events;
4
5
use ValueObjects\Identity\UUID;
6
7
abstract class AbstractLabelEvent extends AbstractEvent
8
{
9
    public const LABEL_ID = 'labelId';
10
11
    /**
12
     * @var UUID
13
     */
14
    private $labelId;
15
16
    final public function __construct(
17
        UUID $uuid,
18
        UUID $labelId
19
    ) {
20
        parent::__construct($uuid);
21
        $this->labelId = $labelId;
22
    }
23
24
    public function getLabelId(): UUID
25
    {
26
        return $this->labelId;
27
    }
28
29
    public static function deserialize(array $data): AbstractLabelEvent
30
    {
31
        return new static(
32
            new UUID($data[self::UUID]),
33
            new UUID($data[self::LABEL_ID])
34
        );
35
    }
36
37
    public function serialize(): array
38
    {
39
        return parent::serialize() + [self::LABEL_ID => $this->getLabelId()->toNative()];
40
    }
41
}
42