Completed
Pull Request — master (#478)
by Luc
02:16
created

SubEventStatusUpdated   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 60
c 0
b 0
f 0
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A serialize() 0 8 1
A deserialize() 0 8 1
A getEventId() 0 4 1
A getTimestamp() 0 4 1
A getReason() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace CultuurNet\UDB3\Event\Events\Status;
6
7
use CultuurNet\UDB3\Timestamp;
8
9
abstract class SubEventStatusUpdated
10
{
11
    /**
12
     * @var string
13
     */
14
    private $eventId;
15
16
    /**
17
     * @var Timestamp
18
     */
19
    private $timestamp;
20
21
    /**
22
     * @var string
23
     */
24
    private $reason;
25
26
    final public function __construct(string $eventId, Timestamp $timestamp, string $reason)
27
    {
28
        $this->eventId = $eventId;
29
        $this->timestamp = $timestamp;
30
        $this->reason = $reason;
31
    }
32
33
    public function serialize(): array
34
    {
35
        return [
36
            'eventId' => $this->eventId,
37
            'timestamp' => $this->timestamp->serialize(),
38
            'reason' => $this->reason,
39
        ];
40
    }
41
42
    /**
43
     * @return static
44
     */
45
    public static function deserialize(array $data)
46
    {
47
        return new static(
48
            $data['eventId'],
49
            Timestamp::deserialize($data['timestamp']),
50
            $data['reason']
51
        );
52
    }
53
54
    public function getEventId(): string
55
    {
56
        return $this->eventId;
57
    }
58
59
    public function getTimestamp(): Timestamp
60
    {
61
        return $this->timestamp;
62
    }
63
64
    public function getReason(): string
65
    {
66
        return $this->reason;
67
    }
68
}
69