Completed
Pull Request — master (#121)
by Kristof
05:12
created

ImageRemoveTrait::getImage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace CultuurNet\UDB3\Offer;
4
5
use CultuurNet\UDB3\Media\Image;
6
7
/**
8
 * Provides a trait for deleting an image commands.
9
 */
10
trait ImageRemoveTrait
11
{
12
    /**
13
     * @var string
14
     */
15
    protected $itemId;
16
17
    /**
18
     * @var Image
19
     */
20
    protected $image;
21
22
    /**
23
     * @param string $id
24
     * @param Image $image
25
     */
26
    public function __construct($id, Image $image)
27
    {
28
        $this->itemId = $id;
29
        $this->image = $image;
30
    }
31
32
    /**
33
     * @return string
34
     */
35
    public function getItemId()
36
    {
37
        return $this->itemId;
38
    }
39
40
    /**
41
     * @return Image
42
     */
43
    public function getImage()
44
    {
45
        return $this->image;
46
    }
47
48
    public function serialize()
49
    {
50
        return array(
51
            'item_id' => $this->itemId,
52
            'image' => $this->image->serialize()
53
        );
54
    }
55
56
    public static function deserialize(array $data)
57
    {
58
        return new static(
59
            $data['item_id'],
60
            Image::deserialize($data['image'])
61
        );
62
    }
63
}
64