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