Completed
Pull Request — master (#394)
by Kristof
04:20
created

AbstractConstraintEvent::getSapiVersion()   A

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 CultuurNet\UDB3\Role\ValueObjects\Query;
6
use CultuurNet\UDB3\ValueObject\SapiVersion;
7
use ValueObjects\Identity\UUID;
8
9
class AbstractConstraintEvent extends AbstractEvent
10
{
11
    /**
12
     * @var SapiVersion
13
     */
14
    private $sapiVersion;
15
16
    /**
17
     * @var Query
18
     */
19
    private $query;
20
21
    /**
22
     * AbstractPermissionEvent constructor.
23
     * @param UUID $uuid
24
     * @param SapiVersion $sapiVersion
25
     * @param Query $query
26
     */
27
    public function __construct(
28
        UUID $uuid,
29
        SapiVersion $sapiVersion,
30
        Query $query
31
    ) {
32
        parent::__construct($uuid);
33
        $this->sapiVersion = $sapiVersion;
34
        $this->query = $query;
35
    }
36
37
    /**
38
     * @return SapiVersion
39
     */
40
    public function getSapiVersion(): SapiVersion
41
    {
42
        return $this->sapiVersion;
43
    }
44
45
    /**
46
     * @return Query
47
     */
48
    public function getQuery(): Query
49
    {
50
        return $this->query;
51
    }
52
53
    /**
54
     * @inheritdoc
55
     */
56
    public static function deserialize(array $data)
57
    {
58
        return new static(
59
            new UUID($data['uuid']),
60
            SapiVersion::fromNative($data['sapiVersion']),
61
            new Query($data['query'])
62
        );
63
    }
64
65
    /**
66
     * @inheritdoc
67
     */
68
    public function serialize()
69
    {
70
        return parent::serialize() + array(
71
            'sapiVersion' => $this->sapiVersion->toNative(),
72
            'query' => $this->query->toNative(),
73
        );
74
    }
75
}
76