Completed
Push — master ( d252f0...d75c62 )
by Jonas
22s queued 11s
created

AbstractImageUpdated::getItemId()   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\Offer\Events\Image;
4
5
use CultuurNet\UDB3\Offer\Events\AbstractEvent;
6
use ValueObjects\Identity\UUID;
7
use ValueObjects\StringLiteral\StringLiteral;
8
9
abstract class AbstractImageUpdated extends AbstractEvent
10
{
11
    /**
12
     * @var UUID
13
     */
14
    protected $mediaObjectId;
15
16
    /**
17
     * @var StringLiteral
18
     */
19
    protected $description;
20
21
    /**
22
     * @var StringLiteral
23
     */
24
    protected $copyrightHolder;
25
26
    final public function __construct(
27
        string $itemId,
28
        UUID $mediaObjectId,
29
        StringLiteral $description,
30
        StringLiteral $copyrightHolder
31
    ) {
32
        parent::__construct($itemId);
33
        $this->mediaObjectId = $mediaObjectId;
34
        $this->description = $description;
35
        $this->copyrightHolder = $copyrightHolder;
36
    }
37
38
    /**
39
     * @return UUID
40
     */
41
    public function getMediaObjectId(): UUID
42
    {
43
        return $this->mediaObjectId;
44
    }
45
46
    public function getDescription(): StringLiteral
47
    {
48
        return $this->description;
49
    }
50
51
    public function getCopyrightHolder(): StringLiteral
52
    {
53
        return $this->copyrightHolder;
54
    }
55
56
    public function serialize(): array
57
    {
58
        return parent::serialize() +  array(
59
            'media_object_id' => (string) $this->mediaObjectId,
60
            'description' => (string) $this->description,
61
            'copyright_holder' => (string) $this->copyrightHolder,
62
        );
63
    }
64
65
    public static function deserialize(array $data): AbstractImageUpdated
66
    {
67
        return new static(
68
            $data['item_id'],
69
            new UUID($data['media_object_id']),
70
            new StringLiteral($data['description']),
71
            new StringLiteral($data['copyright_holder'])
72
        );
73
    }
74
}
75