1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace CultuurNet\UDB3\Media\Commands; |
4
|
|
|
|
5
|
|
|
use CultuurNet\UDB3\Language; |
6
|
|
|
use CultuurNet\UDB3\Media\Properties\MIMEType; |
7
|
|
|
use CultuurNet\UDB3\Offer\Commands\AuthorizableCommandInterface; |
8
|
|
|
use CultuurNet\UDB3\Role\ValueObjects\Permission; |
9
|
|
|
use ValueObjects\Identity\UUID; |
10
|
|
|
use ValueObjects\StringLiteral\StringLiteral; |
11
|
|
|
|
12
|
|
|
class UploadImage implements AuthorizableCommandInterface |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* @var UUID |
16
|
|
|
*/ |
17
|
|
|
protected $fileId; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @var Language |
21
|
|
|
*/ |
22
|
|
|
protected $language; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var StringLiteral |
26
|
|
|
*/ |
27
|
|
|
protected $description; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var StringLiteral |
31
|
|
|
*/ |
32
|
|
|
protected $copyrightHolder; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var MIMEType |
36
|
|
|
*/ |
37
|
|
|
protected $mimeType; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var StringLiteral |
41
|
|
|
*/ |
42
|
|
|
protected $filePath; |
43
|
|
|
/** |
44
|
|
|
* @param UUID $fileId |
45
|
|
|
* @param MIMEType $mimeType |
46
|
|
|
* @param StringLiteral $description |
47
|
|
|
* @param StringLiteral $copyrightHolder |
48
|
|
|
* @param StringLiteral $filePath |
49
|
|
|
* @param Language $language |
50
|
|
|
*/ |
51
|
|
View Code Duplication |
public function __construct( |
|
|
|
|
52
|
|
|
UUID $fileId, |
53
|
|
|
MIMEType $mimeType, |
54
|
|
|
StringLiteral $description, |
55
|
|
|
StringLiteral $copyrightHolder, |
56
|
|
|
StringLiteral $filePath, |
57
|
|
|
Language $language |
58
|
|
|
) { |
59
|
|
|
$this->fileId = $fileId; |
60
|
|
|
$this->description = $description; |
61
|
|
|
$this->copyrightHolder = $copyrightHolder; |
62
|
|
|
$this->mimeType = $mimeType; |
63
|
|
|
$this->filePath = $filePath; |
64
|
|
|
$this->language = $language; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @return Language |
69
|
|
|
*/ |
70
|
|
|
public function getLanguage() |
71
|
|
|
{ |
72
|
|
|
return $this->language; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @return UUID |
77
|
|
|
*/ |
78
|
|
|
public function getFileId() |
79
|
|
|
{ |
80
|
|
|
return $this->fileId; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @return StringLiteral |
85
|
|
|
*/ |
86
|
|
|
public function getDescription() |
87
|
|
|
{ |
88
|
|
|
return $this->description; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @return StringLiteral |
93
|
|
|
*/ |
94
|
|
|
public function getCopyrightHolder() |
95
|
|
|
{ |
96
|
|
|
return $this->copyrightHolder; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @return MIMEType |
101
|
|
|
*/ |
102
|
|
|
public function getMimeType() |
103
|
|
|
{ |
104
|
|
|
return $this->mimeType; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* @return StringLiteral |
109
|
|
|
*/ |
110
|
|
|
public function getFilePath() |
111
|
|
|
{ |
112
|
|
|
return $this->filePath; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
public function getItemId() |
116
|
|
|
{ |
117
|
|
|
return (string) $this->getFileId(); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
public function getPermission() |
121
|
|
|
{ |
122
|
|
|
return Permission::MEDIA_UPLOADEN(); |
123
|
|
|
} |
124
|
|
|
} |
125
|
|
|
|
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.