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

StatusUpdated::serialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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