AbstractImageEvent::serialize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
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\Media\Image;
6
use CultuurNet\UDB3\Offer\Events\AbstractEvent;
7
8
abstract class AbstractImageEvent extends AbstractEvent
9
{
10
    /**
11
     * @var Image
12
     */
13
    protected $image;
14
15
    final public function __construct(string $itemId, Image $image)
16
    {
17
        parent::__construct($itemId);
18
        $this->image = $image;
19
    }
20
21
    public function getImage(): Image
22
    {
23
        return $this->image;
24
    }
25
26
    public function serialize(): array
27
    {
28
        return parent::serialize() + array(
29
            'image' => $this->image->serialize(),
30
        );
31
    }
32
33
    public static function deserialize(array $data): AbstractImageEvent
34
    {
35
        return new static(
36
            $data['item_id'],
37
            Image::deserialize($data['image'])
38
        );
39
    }
40
}
41