Completed
Pull Request — master (#394)
by
unknown
05:21
created

AbstractConstraintEvent   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A getSapiVersion() 0 4 1
A getQuery() 0 4 1
A deserialize() 0 8 1
A serialize() 0 7 1
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