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

AbstractImageUpdated   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

6 Methods

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