Image::getMimeType()   A
last analyzed

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\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
final 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
    public function getLanguage(): Language
62
    {
63
        return $this->language;
64
    }
65
66
    public function getMediaObjectId(): UUID
67
    {
68
        return $this->mediaObjectId;
69
    }
70
71
    public function getMimeType(): MIMEType
72
    {
73
        return $this->mimeType;
74
    }
75
76
    public function getDescription(): Description
77
    {
78
        return $this->description;
79
    }
80
81
    public function getCopyrightHolder(): CopyrightHolder
82
    {
83
        return $this->copyrightHolder;
84
    }
85
86
    public function getSourceLocation(): Url
87
    {
88
        return $this->sourceLocation;
89
    }
90
91 View Code Duplication
    public static function deserialize(array $data): Image
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...
92
    {
93
        return new self(
94
            new UUID($data['media_object_id']),
95
            new MIMEType($data['mime_type']),
96
            new Description($data['description']),
97
            new CopyrightHolder($data['copyright_holder']),
98
            Url::fromNative($data['source_location']),
99
            array_key_exists('language', $data) ? new Language($data['language']) : new Language('nl')
100
        );
101
    }
102
103
    public function serialize(): array
104
    {
105
        return [
106
            'media_object_id' => (string) $this->getMediaObjectId(),
107
            'mime_type' => (string) $this->getMimeType(),
108
            'description' => (string) $this->getDescription(),
109
            'copyright_holder' => (string) $this->getCopyrightHolder(),
110
            'source_location' => (string) $this->getSourceLocation(),
111
            'language' => (string) $this->getLanguage(),
112
        ];
113
    }
114
}
115