Completed
Push — master ( ced9b5...a42ee4 )
by Luc
15s
created

UploadImage   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 119
Duplicated Lines 12.61 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 1
dl 15
loc 119
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 15 15 1
A getLanguage() 0 4 1
A getFileId() 0 4 1
A getDescription() 0 4 1
A getCopyrightHolder() 0 4 1
A getMimeType() 0 4 1
A getFilePath() 0 4 1
A getItemId() 0 4 1
A getPermission() 0 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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(
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...
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
    /**
116
     * @inheritdoc
117
     */
118
    public function getItemId()
119
    {
120
        return (string) $this->getFileId();
121
    }
122
123
    /**
124
     * @inheritdoc
125
     */
126
    public function getPermission()
127
    {
128
        return Permission::MEDIA_UPLOADEN();
129
    }
130
}
131