Completed
Push — master ( ccdee4...a3a0e8 )
by Jonas
02:09 queued 10s
created

StatusUpdated   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getId() 0 4 1
A getStatus() 0 4 1
A deserialize() 0 7 1
A serialize() 0 7 1
1
<?php declare(strict_types=1);
2
3
namespace CultuurNet\UDB3\Offer\Events;
4
5
use Broadway\Serializer\SerializableInterface;
6
use CultuurNet\UDB3\Event\ValueObjects\Status;
7
8
class StatusUpdated implements SerializableInterface
9
{
10
    /**
11
     * @var string
12
     */
13
    private $id;
14
15
    /**
16
     * @var Status
17
     */
18
    private $status;
19
20
    public function __construct(string $id, Status $status)
21
    {
22
        $this->id = $id;
23
        $this->status = $status;
24
    }
25
26
    public function getId(): string
27
    {
28
        return $this->id;
29
    }
30
31
    public function getStatus(): Status
32
    {
33
        return $this->status;
34
    }
35
36
    public static function deserialize(array $data): StatusUpdated
37
    {
38
        return new StatusUpdated(
39
            $data['id'],
40
            Status::deserialize($data['status'])
41
        );
42
    }
43
44
    public function serialize(): array
45
    {
46
        return [
47
            'id' => $this->id,
48
            'status' => $this->status->serialize(),
49
        ];
50
    }
51
}
52