Completed
Pull Request — master (#239)
by Luc
04:44
created

AbstractEvent   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getUuid() 0 4 1
A getName() 0 4 1
A deserialize() 0 7 1
A serialize() 0 7 1
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