Completed
Pull Request — master (#239)
by Luc
05:12
created

AbstractEvent::getUuid()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace CultuurNet\UDB3\Label\Events;
4
5
use Broadway\Serializer\SerializableInterface;
6
use CultuurNet\UDB3\Label\ValueObjects\LabelName;
7
use ValueObjects\Identity\UUID;
8
9
abstract class AbstractEvent implements SerializableInterface
10
{
11
    const UUID = 'uuid';
12
    const NAME = 'name';
13
14
    /**
15
     * @var UUID
16
     */
17
    private $uuid;
18
19
    /**
20
     * @var LabelName
21
     */
22
    private $name;
23
24
    /**
25
     * AbstractEvent constructor.
26
     * @param UUID $uuid
27
     * @param LabelName $name
28
     */
29
    public function __construct(UUID $uuid, LabelName $name)
30
    {
31
        $this->uuid = $uuid;
32
        $this->name = $name;
33
    }
34
35
    /**
36
     * @return UUID
37
     */
38
    public function getUuid()
39
    {
40
        return $this->uuid;
41
    }
42
43
    /**
44
     * @return LabelName
45
     */
46
    public function getName()
47
    {
48
        return $this->name;
49
    }
50
51
    /**
52
     * @inheritdoc
53
     */
54
    public static function deserialize(array $data)
55
    {
56
        return new static(
57
            new UUID($data[self::UUID]),
58
            new LabelName($data[self::NAME])
59
        );
60
    }
61
62
    /**
63
     * @inheritdoc
64
     */
65
    public function serialize()
66
    {
67
        return [
68
            self::UUID => $this->getUuid()->toNative(),
69
            self::NAME => $this->getName()->toNative(),
70
        ];
71
    }
72
}
73