Passed
Push — master ( 4aff5b...31f13e )
by David
13:07
created

CardSimpleProperties   A

Complexity

Total Complexity 41

Size/Duplication

Total Lines 264
Duplicated Lines 0 %

Test Coverage

Coverage 81.25%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 41
eloc 84
c 1
b 0
f 0
dl 0
loc 264
ccs 65
cts 80
cp 0.8125
rs 9.1199

38 Methods

Rating   Name   Duplication   Size   Complexity  
A getComment() 0 3 1
A setMuserisUrl() 0 3 1
A setProductionPlace() 0 3 1
A setExpandedName() 0 3 1
A getMuserisUrl() 0 3 1
A getUrlDescription() 0 3 1
A setUrlDescription() 0 3 1
A setTechniqueDate() 0 3 1
A getProductionPlace() 0 3 1
A setObjectReference() 0 3 1
A getFigure() 0 3 1
A setIsbn() 0 3 1
A getFormat() 0 3 1
A setPage() 0 8 2
A setLiterature() 0 3 1
A getRights() 0 3 1
A setRights() 0 3 1
A setCorpus() 0 3 1
A getMaterial() 0 3 1
A getExpandedName() 0 3 1
A setFormat() 0 3 1
A setTable() 0 8 2
A setMaterial() 0 3 1
A getPage() 0 3 1
A getIsbn() 0 3 1
A getTable() 0 3 1
A setFigure() 0 8 2
A getObjectReference() 0 3 1
A getTechniqueDate() 0 3 1
A getLiterature() 0 3 1
A getCorpus() 0 3 1
A setTechniqueAuthor() 0 3 1
A setAddition() 0 3 1
A getTechniqueAuthor() 0 3 1
A getMuserisCote() 0 3 1
A getAddition() 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
    #[ORM\Column(type: 'text', options: ['default' => ''])]
22
    private string $addition = '';
23
24
    #[ORM\Column(type: 'text', options: ['default' => ''])]
25
    private string $expandedName = '';
26
27
    #[ORM\Column(type: 'string', options: ['default' => ''])]
28
    private string $material = '';
29
30
    #[ORM\Column(type: 'string', options: ['default' => ''])]
31
    private string $techniqueAuthor = '';
32
33
    #[ORM\Column(type: 'string', length: 60, options: ['default' => ''])]
34
    private string $techniqueDate = '';
35
36
    #[ORM\Column(type: 'string', options: ['default' => ''])]
37
    private string $format = '';
38
39
    #[ORM\Column(type: 'text', options: ['default' => ''])]
40
    private string $literature = '';
41
42
    #[ORM\Column(type: 'text', options: ['default' => ''])]
43
    private string $objectReference = '';
44
45
    #[ORM\Column(type: 'string', length: 10, options: ['default' => ''])]
46
    private string $page = '';
47
48
    #[ORM\Column(type: 'string', length: 10, options: ['default' => ''])]
49
    private string $figure = '';
50
51
    #[ORM\Column(name: '`table`', type: 'string', length: 10, options: ['default' => ''])]
52
    private string $table = '';
53
54
    #[ORM\Column(type: 'string', length: 30, options: ['default' => ''])]
55
    private string $isbn = '';
56
57
    #[ORM\Column(type: 'text', options: ['default' => ''])]
58
    private string $comment = '';
59
60
    #[ORM\Column(type: 'text', options: ['default' => ''])]
61
    private string $corpus = '';
62
63
    #[ORM\Column(type: 'string', options: ['default' => ''])]
64
    private string $rights = '';
65
66
    #[ORM\Column(type: 'string', options: ['default' => ''])]
67
    private string $muserisUrl = '';
68
69
    #[ORM\Column(type: 'string', options: ['default' => ''])]
70
    private string $muserisCote = '';
71
72
    #[ORM\Column(type: 'string', length: 60, options: ['default' => ''])]
73
    private string $productionPlace = '';
74
75
    #[ORM\Column(type: 'text', options: ['default' => ''])]
76
    private string $urlDescription = '';
77
78
    public function getAddition(): string
79
    {
80
        return $this->addition;
81 3
    }
82
83 3
    public function setAddition(string $addition): void
84
    {
85
        $this->addition = $addition;
86 8
    }
87
88 8
    public function getExpandedName(): string
89
    {
90
        return $this->expandedName;
91 5
    }
92
93 5
    public function setExpandedName(string $expandedName): void
94
    {
95
        $this->expandedName = Utility::sanitizeRichText($expandedName);
96 13
    }
97
98 13
    public function getMaterial(): string
99
    {
100
        return $this->material;
101 4
    }
102
103 4
    public function setMaterial(string $material): void
104
    {
105
        $this->material = $material;
106 8
    }
107
108 8
    public function getTechniqueAuthor(): string
109
    {
110
        return $this->techniqueAuthor;
111 3
    }
112
113 3
    public function setTechniqueAuthor(string $techniqueAuthor): void
114
    {
115
        $this->techniqueAuthor = $techniqueAuthor;
116 8
    }
117
118 8
    public function getTechniqueDate(): string
119
    {
120
        return $this->techniqueDate;
121 3
    }
122
123 3
    public function setTechniqueDate(string $techniqueDate): void
124
    {
125
        $this->techniqueDate = $techniqueDate;
126 9
    }
127
128 9
    public function getFormat(): string
129
    {
130
        return $this->format;
131 3
    }
132
133 3
    public function setFormat(string $format): void
134
    {
135
        $this->format = $format;
136 8
    }
137
138 8
    public function getLiterature(): string
139
    {
140
        return $this->literature;
141 4
    }
142
143 4
    public function setLiterature(string $literature): void
144
    {
145
        $this->literature = Utility::sanitizeRichText($literature);
146 8
    }
147
148 8
    public function getObjectReference(): string
149
    {
150
        return $this->objectReference;
151 3
    }
152
153 3
    public function setObjectReference(string $objectReference): void
154
    {
155
        $this->objectReference = $objectReference;
156 8
    }
157
158 8
    public function getPage(): string
159
    {
160
        return $this->page;
161 3
    }
162
163 3
    public function setPage(string $page): void
164
    {
165
        // Field is readonly and can only be emptied.
166 8
        if ($page !== '') {
167
            return;
168 8
        }
169
170
        $this->page = $page;
171 3
    }
172
173 3
    public function getFigure(): string
174
    {
175
        return $this->figure;
176 8
    }
177
178
    public function setFigure(string $figure): void
179 8
    {
180 8
        // Field is readonly and can only be emptied.
181
        if ($figure !== '') {
182
            return;
183
        }
184
185
        $this->figure = $figure;
186 3
    }
187
188 3
    public function getTable(): string
189
    {
190
        return $this->table;
191 8
    }
192
193
    public function setTable(string $table): void
194 8
    {
195 8
        // Field is readonly and can only be emptied.
196
        if ($table !== '') {
197
            return;
198
        }
199
200
        $this->table = $table;
201 3
    }
202
203 3
    public function getIsbn(): string
204
    {
205
        return $this->isbn;
206 8
    }
207
208
    public function setIsbn(string $isbn): void
209 8
    {
210 8
        $this->isbn = $isbn;
211
    }
212
213
    public function getComment(): string
214
    {
215
        return $this->comment;
216 3
    }
217
218 3
    public function setComment(string $comment): void
219
    {
220
        $this->comment = $comment;
221
    }
222
223
    public function getCorpus(): string
224
    {
225
        return $this->corpus;
226
    }
227
228
    public function setCorpus(string $corpus): void
229
    {
230
        $this->corpus = Utility::sanitizeRichText($corpus);
231 8
    }
232
233 8
    public function getRights(): string
234
    {
235
        return $this->rights;
236
    }
237
238
    public function setRights(string $rights): void
239
    {
240
        $this->rights = $rights;
241 7
    }
242
243 7
    public function getMuserisUrl(): string
244
    {
245
        return $this->muserisUrl;
246
    }
247
248
    public function setMuserisUrl(string $muserisUrl): void
249
    {
250
        $this->muserisUrl = $muserisUrl;
251 8
    }
252
253 8
    public function getMuserisCote(): string
254
    {
255
        return $this->muserisCote;
256
    }
257
258
    public function setMuserisCote(string $muserisCote): void
259
    {
260
        $this->muserisCote = $muserisCote;
261 8
    }
262
263 8
    public function getProductionPlace(): string
264
    {
265
        return $this->productionPlace;
266
    }
267
268
    public function setProductionPlace(string $productionPlace): void
269
    {
270
        $this->productionPlace = $productionPlace;
271 8
    }
272
273 8
    public function getUrlDescription(): string
274
    {
275
        return $this->urlDescription;
276 3
    }
277
278 3
    public function setUrlDescription(string $urlDescription): void
279
    {
280
        $this->urlDescription = Utility::sanitizeRichText($urlDescription);
281 8
    }
282
}
283