Passed
Push — master ( 5c4b0c...475b00 )
by
unknown
04:15
created

CardSimpleProperties   B

Complexity

Total Complexity 43

Size/Duplication

Total Lines 337
Duplicated Lines 0 %

Test Coverage

Coverage 80.23%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 43
eloc 88
c 2
b 0
f 0
dl 0
loc 337
ccs 69
cts 86
cp 0.8023
rs 8.96

40 Methods

Rating   Name   Duplication   Size   Complexity  
A getComment() 0 3 1
A setExpandedName() 0 3 1
A getDilpsDomain() 0 3 1
A setTechniqueDate() 0 3 1
A setObjectReference() 0 3 1
A getFormat() 0 3 1
A setLiterature() 0 3 1
A setDilpsDomain() 0 3 1
A getMaterial() 0 3 1
A getExpandedName() 0 3 1
A setFormat() 0 3 1
A setMaterial() 0 3 1
A getPage() 0 3 1
A getObjectReference() 0 3 1
A getTechniqueDate() 0 3 1
A getLiterature() 0 3 1
A setTechniqueAuthor() 0 3 1
A setAddition() 0 3 1
A getTechniqueAuthor() 0 3 1
A getAddition() 0 3 1
A setMuserisUrl() 0 3 1
A getProductionPlace() 0 3 1
A getFigure() 0 3 1
A setIsbn() 0 3 1
A getIsbn() 0 3 1
A getTable() 0 3 1
A setProductionPlace() 0 3 1
A getMuserisUrl() 0 3 1
A getUrlDescription() 0 3 1
A setUrlDescription() 0 3 1
A setPage() 0 8 2
A getRights() 0 3 1
A setRights() 0 3 1
A setCorpus() 0 3 1
A setTable() 0 8 2
A setFigure() 0 8 2
A getCorpus() 0 3 1
A getMuserisCote() 0 3 1
A setComment() 0 3 1
A setMuserisCote() 0 3 1

How to fix   Complexity   

Complex Class

Complex classes like CardSimpleProperties often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use CardSimpleProperties, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
declare(strict_types=1);
4
5
namespace Application\Traits;
6
7
use Application\Utility;
8
use Doctrine\ORM\Mapping as ORM;
9
use Ecodev\Felix\Model\Traits\HasUrl;
10
11
/**
12
 * Trait for "simple" properties of an card.
13
 *
14
 * They are mostly what was called "meta" in the old DILPS. And we split
15
 * them only to reduce the Card class size to focus on most important code.
16
 */
17
trait CardSimpleProperties
18
{
19
    use HasUrl;
20
21
    /**
22
     * @var string
23
     */
24
    #[ORM\Column(type: 'text', options: ['default' => ''])]
25
    private $addition = '';
26
27
    /**
28
     * @var string
29
     */
30
    #[ORM\Column(type: 'text', options: ['default' => ''])]
31
    private $expandedName = '';
32
33
    /**
34
     * @var string
35
     */
36
    #[ORM\Column(type: 'string', options: ['default' => ''])]
37
    private $material = '';
38
39
    /**
40
     * @var string
41
     */
42
    #[ORM\Column(type: 'string', options: ['default' => ''])]
43
    private $dilpsDomain = '';
44
45
    /**
46
     * @var string
47
     */
48
    #[ORM\Column(type: 'string', options: ['default' => ''])]
49
    private $techniqueAuthor = '';
50
51
    /**
52
     * @var string
53
     */
54
    #[ORM\Column(type: 'string', length: 60, options: ['default' => ''])]
55
    private $techniqueDate = '';
56
57
    /**
58
     * @var string
59
     */
60
    #[ORM\Column(type: 'string', options: ['default' => ''])]
61
    private $format = '';
62
63
    /**
64
     * @var string
65
     */
66
    #[ORM\Column(type: 'text', options: ['default' => ''])]
67
    private $literature = '';
68
69
    /**
70
     * @var string
71
     */
72
    #[ORM\Column(type: 'text', options: ['default' => ''])]
73
    private $objectReference = '';
74
75
    /**
76
     * @var string
77
     */
78
    #[ORM\Column(type: 'string', length: 10, options: ['default' => ''])]
79
    private $page = '';
80
81
    /**
82
     * @var string
83
     */
84
    #[ORM\Column(type: 'string', length: 10, options: ['default' => ''])]
85
    private $figure = '';
86
87
    /**
88
     * @var string
89
     */
90
    #[ORM\Column(name: '`table`', type: 'string', length: 10, options: ['default' => ''])]
91
    private $table = '';
92
93
    /**
94
     * @var string
95
     */
96
    #[ORM\Column(type: 'string', length: 30, options: ['default' => ''])]
97
    private $isbn = '';
98
99
    /**
100
     * @var string
101
     */
102
    #[ORM\Column(type: 'text')]
103
    private $comment = '';
104
105
    /**
106
     * @var string
107
     */
108
    #[ORM\Column(type: 'text')]
109
    private $corpus = '';
110
111
    /**
112
     * @var string
113
     */
114
    #[ORM\Column(type: 'string', options: ['default' => ''])]
115
    private $rights = '';
116
117
    /**
118
     * @var string
119
     */
120
    #[ORM\Column(type: 'string', options: ['default' => ''])]
121
    private $muserisUrl = '';
122
123
    /**
124
     * @var string
125
     */
126
    #[ORM\Column(type: 'string', options: ['default' => ''])]
127
    private $muserisCote = '';
128
129
    /**
130
     * @var string
131
     */
132
    #[ORM\Column(type: 'string', length: 60, options: ['default' => ''])]
133
    private $productionPlace = '';
134
135
    /**
136
     * @var string
137
     */
138
    #[ORM\Column(type: 'text', options: ['default' => ''])]
139
    private $urlDescription = '';
140
141 3
    public function getAddition(): string
142
    {
143 3
        return $this->addition;
144
    }
145
146 8
    public function setAddition(string $addition): void
147
    {
148 8
        $this->addition = $addition;
149
    }
150
151 5
    public function getExpandedName(): string
152
    {
153 5
        return $this->expandedName;
154
    }
155
156 13
    public function setExpandedName(string $expandedName): void
157
    {
158 13
        $this->expandedName = Utility::sanitizeRichText($expandedName);
159
    }
160
161 4
    public function getMaterial(): string
162
    {
163 4
        return $this->material;
164
    }
165
166 8
    public function setMaterial(string $material): void
167
    {
168 8
        $this->material = $material;
169
    }
170
171 3
    public function getDilpsDomain(): string
172
    {
173 3
        return $this->dilpsDomain;
174
    }
175
176 8
    public function setDilpsDomain(string $dilpsDomain): void
177
    {
178 8
        $this->dilpsDomain = $dilpsDomain;
179
    }
180
181 3
    public function getTechniqueAuthor(): string
182
    {
183 3
        return $this->techniqueAuthor;
184
    }
185
186 9
    public function setTechniqueAuthor(string $techniqueAuthor): void
187
    {
188 9
        $this->techniqueAuthor = $techniqueAuthor;
189
    }
190
191 3
    public function getTechniqueDate(): string
192
    {
193 3
        return $this->techniqueDate;
194
    }
195
196 8
    public function setTechniqueDate(string $techniqueDate): void
197
    {
198 8
        $this->techniqueDate = $techniqueDate;
199
    }
200
201 4
    public function getFormat(): string
202
    {
203 4
        return $this->format;
204
    }
205
206 8
    public function setFormat(string $format): void
207
    {
208 8
        $this->format = $format;
209
    }
210
211 3
    public function getLiterature(): string
212
    {
213 3
        return $this->literature;
214
    }
215
216 8
    public function setLiterature(string $literature): void
217
    {
218 8
        $this->literature = Utility::sanitizeRichText($literature);
219
    }
220
221 3
    public function getObjectReference(): string
222
    {
223 3
        return $this->objectReference;
224
    }
225
226 8
    public function setObjectReference(string $objectReference): void
227
    {
228 8
        $this->objectReference = $objectReference;
229
    }
230
231 3
    public function getPage(): string
232
    {
233 3
        return $this->page;
234
    }
235
236 8
    public function setPage(string $page): void
237
    {
238
        // Field is readonly and can only be emptied.
239 8
        if ($page !== '') {
240 8
            return;
241
        }
242
243
        $this->page = $page;
244
    }
245
246 3
    public function getFigure(): string
247
    {
248 3
        return $this->figure;
249
    }
250
251 8
    public function setFigure(string $figure): void
252
    {
253
        // Field is readonly and can only be emptied.
254 8
        if ($figure !== '') {
255 8
            return;
256
        }
257
258
        $this->figure = $figure;
259
    }
260
261 3
    public function getTable(): string
262
    {
263 3
        return $this->table;
264
    }
265
266 8
    public function setTable(string $table): void
267
    {
268
        // Field is readonly and can only be emptied.
269 8
        if ($table !== '') {
270 8
            return;
271
        }
272
273
        $this->table = $table;
274
    }
275
276 3
    public function getIsbn(): string
277
    {
278 3
        return $this->isbn;
279
    }
280
281
    public function setIsbn(string $isbn): void
282
    {
283
        $this->isbn = $isbn;
284
    }
285
286
    public function getComment(): string
287
    {
288
        return $this->comment;
289
    }
290
291 8
    public function setComment(string $comment): void
292
    {
293 8
        $this->comment = $comment;
294
    }
295
296
    public function getCorpus(): string
297
    {
298
        return $this->corpus;
299
    }
300
301 7
    public function setCorpus(string $corpus): void
302
    {
303 7
        $this->corpus = Utility::sanitizeRichText($corpus);
304
    }
305
306
    public function getRights(): string
307
    {
308
        return $this->rights;
309
    }
310
311 8
    public function setRights(string $rights): void
312
    {
313 8
        $this->rights = $rights;
314
    }
315
316
    public function getMuserisUrl(): string
317
    {
318
        return $this->muserisUrl;
319
    }
320
321 8
    public function setMuserisUrl(string $muserisUrl): void
322
    {
323 8
        $this->muserisUrl = $muserisUrl;
324
    }
325
326
    public function getMuserisCote(): string
327
    {
328
        return $this->muserisCote;
329
    }
330
331 8
    public function setMuserisCote(string $muserisCote): void
332
    {
333 8
        $this->muserisCote = $muserisCote;
334
    }
335
336 3
    public function getProductionPlace(): string
337
    {
338 3
        return $this->productionPlace;
339
    }
340
341 8
    public function setProductionPlace(string $productionPlace): void
342
    {
343 8
        $this->productionPlace = $productionPlace;
344
    }
345
346
    public function getUrlDescription(): string
347
    {
348
        return $this->urlDescription;
349
    }
350
351 7
    public function setUrlDescription(string $urlDescription): void
352
    {
353 7
        $this->urlDescription = Utility::sanitizeRichText($urlDescription);
354
    }
355
}
356