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 namespace Nord\Lumen\ImageManager\Adapters\Cloudinary; |
||
3 | class CloudinaryUploadParameters |
||
4 | { |
||
5 | const RESOURCE_TYPE_IMAGE = 'image'; |
||
6 | const RESOURCE_TYPE_RAW = 'raw'; |
||
7 | const RESOURCE_TYPE_AUTO = 'auto'; |
||
8 | const TYPE_UPLOAD = 'upload'; |
||
9 | const TYPE_PUBLIC = 'public'; |
||
10 | const TYPE_AUTHENTICATED = 'authenticated'; |
||
11 | const RAW_CONVERT_ASPOSE = 'aspose'; |
||
12 | const CATEGORIZATION_REKOGNITION_SCENE = 'rekognition_scene'; |
||
13 | const DETECTION_REKOGNITION_FACE = 'rekognition_face'; |
||
14 | const MODERATION_MANUAL = 'manual'; |
||
15 | const MODERATION_WEBPURIFY = 'webpurify'; |
||
16 | |||
17 | /** |
||
18 | * @var string |
||
19 | */ |
||
20 | public $publicId; |
||
21 | |||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | public $resourceType; |
||
26 | |||
27 | /** |
||
28 | * @var string |
||
29 | */ |
||
30 | public $type; |
||
31 | |||
32 | /** |
||
33 | * @var array |
||
34 | */ |
||
35 | public $tags; |
||
36 | |||
37 | /** |
||
38 | * @var array |
||
39 | */ |
||
40 | public $context; |
||
41 | |||
42 | /** |
||
43 | * @var CloudinaryImageTransformation |
||
44 | */ |
||
45 | public $transformation; |
||
46 | |||
47 | /** |
||
48 | * @var string |
||
49 | */ |
||
50 | public $format; |
||
51 | |||
52 | /** |
||
53 | * @var string|array |
||
54 | */ |
||
55 | public $allowedFormats; |
||
56 | |||
57 | /** |
||
58 | * @var array |
||
59 | */ |
||
60 | public $eager; |
||
61 | |||
62 | /** |
||
63 | * @var boolean |
||
64 | */ |
||
65 | public $eagerAsync; |
||
66 | |||
67 | /** |
||
68 | * @var string |
||
69 | */ |
||
70 | public $proxy; |
||
71 | |||
72 | /** |
||
73 | * @var string|array |
||
74 | */ |
||
75 | public $headers; |
||
76 | |||
77 | /** |
||
78 | * @var string |
||
79 | */ |
||
80 | public $callback; |
||
81 | |||
82 | /** |
||
83 | * @var string |
||
84 | */ |
||
85 | public $notificationUrl; |
||
86 | |||
87 | /** |
||
88 | * @var string |
||
89 | */ |
||
90 | public $eagerNotificationUrl; |
||
91 | |||
92 | /** |
||
93 | * @var boolean |
||
94 | */ |
||
95 | public $backup; |
||
96 | |||
97 | /** |
||
98 | * @var boolean |
||
99 | */ |
||
100 | public $returnDeleteToken; |
||
101 | |||
102 | /** |
||
103 | * @var boolean |
||
104 | */ |
||
105 | public $faces; |
||
106 | |||
107 | /** |
||
108 | * @var boolean |
||
109 | */ |
||
110 | public $exif; |
||
111 | |||
112 | /** |
||
113 | * @var boolean |
||
114 | */ |
||
115 | public $colors; |
||
116 | |||
117 | /** |
||
118 | * @var boolean |
||
119 | */ |
||
120 | public $imageMetadata; |
||
121 | |||
122 | /** |
||
123 | * @var boolean |
||
124 | */ |
||
125 | public $pHash; |
||
126 | |||
127 | /** |
||
128 | * @var boolean |
||
129 | */ |
||
130 | public $invalidate; |
||
131 | |||
132 | /** |
||
133 | * @var boolean |
||
134 | */ |
||
135 | public $useFilename; |
||
136 | |||
137 | /** |
||
138 | * @var boolean |
||
139 | */ |
||
140 | public $uniqueFilename; |
||
141 | |||
142 | /** |
||
143 | * @var string |
||
144 | */ |
||
145 | public $folder; |
||
146 | |||
147 | /** |
||
148 | * @var boolean |
||
149 | */ |
||
150 | public $overwrite; |
||
151 | |||
152 | /** |
||
153 | * @var boolean |
||
154 | */ |
||
155 | public $discardOriginalFilename; |
||
156 | |||
157 | /** |
||
158 | * @var string |
||
159 | */ |
||
160 | public $faceCoordinates; |
||
161 | |||
162 | /** |
||
163 | * @var string |
||
164 | */ |
||
165 | public $customCoordinates; |
||
166 | |||
167 | /** |
||
168 | * @var string |
||
169 | */ |
||
170 | public $rawConvert; |
||
171 | |||
172 | /** |
||
173 | * @var string |
||
174 | */ |
||
175 | public $categorization; |
||
176 | |||
177 | /** |
||
178 | * @var float |
||
179 | */ |
||
180 | public $autoTagging; |
||
181 | |||
182 | /** |
||
183 | * @var string |
||
184 | */ |
||
185 | public $detection; |
||
186 | |||
187 | /** |
||
188 | * @var string |
||
189 | */ |
||
190 | public $moderation; |
||
191 | |||
192 | /** |
||
193 | * @var string |
||
194 | */ |
||
195 | public $uploadPreset; |
||
196 | |||
197 | /** |
||
198 | * @var array |
||
199 | */ |
||
200 | public $html; |
||
201 | |||
202 | |||
203 | /** |
||
204 | * CloudinaryUploadParameters constructor. |
||
205 | * |
||
206 | * @param array $properties |
||
207 | */ |
||
208 | View Code Duplication | public function __construct(array $properties) |
|
219 | |||
220 | |||
221 | /** |
||
222 | * @return CloudinaryImageTransformation |
||
223 | */ |
||
224 | public function getTransformation() |
||
228 | |||
229 | |||
230 | /** |
||
231 | * @return array |
||
232 | */ |
||
233 | public function getAllowedFormats() |
||
237 | |||
238 | |||
239 | /** |
||
240 | * @return array |
||
241 | */ |
||
242 | View Code Duplication | public function toArray() |
|
257 | } |
||
258 |
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.