Completed
Pull Request — master (#311)
by
unknown
04:10
created

Image::getLanguage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace CultuurNet\UDB3\Media;
4
5
use Broadway\Serializer\SerializableInterface;
6
use CultuurNet\UDB3\Language;
7
use CultuurNet\UDB3\Media\Properties\MIMEType;
8
use CultuurNet\UDB3\Media\Properties\CopyrightHolder;
9
use CultuurNet\UDB3\Media\Properties\Description;
10
use ValueObjects\Identity\UUID;
11
use ValueObjects\Web\Url;
12
13
class Image implements SerializableInterface
14
{
15
    /**
16
     * @var UUID
17
     */
18
    protected $mediaObjectId;
19
20
    /**
21
     * @var MIMEType
22
     */
23
    protected $mimeType;
24
25
    /**
26
     * @var Description
27
     */
28
    protected $description;
29
30
    /**
31
     * @var CopyrightHolder
32
     */
33
    protected $copyrightHolder;
34
35
    /**
36
     * @var Url
37
     */
38
    protected $sourceLocation;
39
40
    /**
41
     * @var Language
42
     */
43
    protected $language;
44
45 View Code Duplication
    public function __construct(
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
46
        UUID $id,
47
        MIMEType $mimeType,
48
        Description $description,
49
        CopyrightHolder $copyrightHolder,
50
        Url $sourceLocation,
51
        Language $language
52
    ) {
53
        $this->mediaObjectId = $id;
54
        $this->mimeType = $mimeType;
55
        $this->description = $description;
56
        $this->copyrightHolder = $copyrightHolder;
57
        $this->sourceLocation = $sourceLocation;
58
        $this->language = $language;
59
    }
60
61
    /**
62
     * @return Language
63
     */
64
    public function getLanguage()
65
    {
66
        return $this->language;
67
    }
68
69
    /**
70
     * @return UUID
71
     */
72
    public function getMediaObjectId()
73
    {
74
        return $this->mediaObjectId;
75
    }
76
77
    /**
78
     * @return MIMEType
79
     */
80
    public function getMimeType()
81
    {
82
        return $this->mimeType;
83
    }
84
85
    /**
86
     * @return Description
87
     */
88
    public function getDescription()
89
    {
90
        return $this->description;
91
    }
92
93
    /**
94
     * @return CopyrightHolder
95
     */
96
    public function getCopyrightHolder()
97
    {
98
        return $this->copyrightHolder;
99
    }
100
101
    /**
102
     * @return Url
103
     */
104
    public function getSourceLocation()
105
    {
106
        return $this->sourceLocation;
107
    }
108
109
    /**
110
     * {@inheritdoc}
111
     */
112 View Code Duplication
    public static function deserialize(array $data)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
113
    {
114
        return new static(
115
            new UUID($data['media_object_id']),
116
            new MIMEType($data['mime_type']),
117
            new Description($data['description']),
118
            new CopyrightHolder($data['copyright_holder']),
119
            Url::fromNative($data['source_location']),
120
            array_key_exists('language', $data) ? new Language($data['language']) : new Language('nl')
121
        );
122
    }
123
124
    /**
125
     * {@inheritdoc}
126
     */
127
    public function serialize()
128
    {
129
        return [
130
            'media_object_id' => (string) $this->getMediaObjectId(),
131
            'mime_type' => (string) $this->getMimeType(),
132
            'description' => (string) $this->getDescription(),
133
            'copyright_holder' => (string) $this->getCopyrightHolder(),
134
            'source_location' => (string) $this->getSourceLocation(),
135
            'language' => (string) $this->getLanguage()
136
        ];
137
    }
138
}
139