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

MediaObject::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\EventSourcing\EventSourcedAggregateRoot;
6
use CultuurNet\UDB3\Language;
7
use CultuurNet\UDB3\Media\Events\MediaObjectCreated;
8
use CultuurNet\UDB3\Media\Properties\MIMEType;
9
use ValueObjects\Identity\UUID;
10
use ValueObjects\StringLiteral\StringLiteral;
11
use ValueObjects\Web\Url;
12
13
/**
14
 * MediaObjects for UDB3.
15
 */
16
class MediaObject extends EventSourcedAggregateRoot
17
{
18
    /**
19
     * Mime type of the media object.
20
     *
21
     * @var MIMEType
22
     */
23
    protected $mimeType;
24
25
    /**
26
     * The id of the media object.
27
     *
28
     * @var UUID
29
     */
30
    protected $mediaObjectId;
31
32
    /**
33
     * Description of the media object.
34
     *
35
     * @var StringLiteral
36
     */
37
    protected $description;
38
39
    /**
40
     * Copyright info.
41
     *
42
     * @var StringLiteral
43
     */
44
    protected $copyrightHolder;
45
46
    /**
47
     * The URL where the source file can be found.
48
     * @var Url
49
     */
50
    protected $sourceLocation;
51
52
    /**
53
     * @var Language
54
     */
55
    protected $language;
56
57
    /**
58
     * @param UUID $id
59
     * @param MIMEType $mimeType
60
     * @param StringLiteral $description
61
     * @param StringLiteral $copyrightHolder
62
     * @param Url $sourceLocation
63
     * @param Language $language
64
     *
65
     * @return MediaObject
66
     */
67
    public static function create(
68
        UUID $id,
69
        MIMEType $mimeType,
70
        StringLiteral $description,
71
        StringLiteral $copyrightHolder,
72
        Url $sourceLocation,
73
        Language $language
74
    ) {
75
        $mediaObject = new self();
76
        $mediaObject->apply(
77
            new MediaObjectCreated(
78
                $id,
79
                $mimeType,
80
                $description,
81
                $copyrightHolder,
82
                $sourceLocation,
83
                $language
84
            )
85
        );
86
87
        return $mediaObject;
88
    }
89
90
    /**
91
     * {@inheritdoc}
92
     */
93
    public function getAggregateRootId()
94
    {
95
        return $this->mediaObjectId;
96
    }
97
98
    protected function applyMediaObjectCreated(MediaObjectCreated $mediaObjectCreated)
99
    {
100
        $this->mediaObjectId = $mediaObjectCreated->getMediaObjectId();
101
        $this->mimeType = $mediaObjectCreated->getMimeType();
102
        $this->description = $mediaObjectCreated->getDescription();
0 ignored issues
show
Documentation Bug introduced by
It seems like $mediaObjectCreated->getDescription() of type string is incompatible with the declared type object<ValueObjects\StringLiteral\StringLiteral> of property $description.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
103
        $this->copyrightHolder = $mediaObjectCreated->getCopyrightHolder();
0 ignored issues
show
Documentation Bug introduced by
It seems like $mediaObjectCreated->getCopyrightHolder() of type string is incompatible with the declared type object<ValueObjects\StringLiteral\StringLiteral> of property $copyrightHolder.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
104
        $this->sourceLocation = $mediaObjectCreated->getSourceLocation();
105
        $this->language = $mediaObjectCreated->getLanguage();
106
    }
107
108
    /**
109
     * @return StringLiteral
110
     */
111
    public function getDescription()
112
    {
113
        return $this->description;
114
    }
115
116
    /**
117
     * @return StringLiteral
118
     */
119
    public function getCopyrightHolder()
120
    {
121
        return $this->copyrightHolder;
122
    }
123
124
    /**
125
     * @return UUID
126
     */
127
    public function getMediaObjectId()
128
    {
129
        return $this->mediaObjectId;
130
    }
131
132
    /**
133
     * @return MIMEType
134
     */
135
    public function getMimeType()
136
    {
137
        return $this->mimeType;
138
    }
139
140
    /**
141
     * @return Url
142
     */
143
    public function getSourceLocation()
144
    {
145
        return $this->sourceLocation;
146
    }
147
148
    /**
149
     * @return Language
150
     */
151
    public function getLanguage()
152
    {
153
        return $this->language;
154
    }
155
}
156