Passed
Push — master ( 8feef3...f9dc8e )
by Petr
09:08 queued 06:38
created

Translations   A

Complexity

Total Complexity 41

Size/Duplication

Total Lines 245
Duplicated Lines 0 %

Test Coverage

Coverage 75.61%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 42
c 1
b 0
f 0
dl 0
loc 245
ccs 62
cts 82
cp 0.7561
rs 9.1199
wmc 41

41 Methods

Rating   Name   Duplication   Size   Complexity  
A imWrongMime() 0 3 1
A imThumbCannotMoveBase() 0 3 1
A imDescCannotMoveBase() 0 3 1
A imImageCannotFind() 0 3 1
A imDescAlreadyExistsHere() 0 3 1
A imThumbCannotFind() 0 3 1
A imDescCannotRemoveOld() 0 3 1
A imThumbCannotRenameBase() 0 3 1
A imImageCannotRemoveOld() 0 3 1
A imImageSizeTooLarge() 0 3 1
A imImageLoadFirst() 0 3 1
A imDescCannotRenameBase() 0 3 1
A imImageAlreadyExistsHere() 0 3 1
A imThumbCannotRemoveOld() 0 3 1
A imUnknownType() 0 3 1
A imDirThumbCannotRemoveCurrent() 0 3 1
A imDescCannotRemove() 0 3 1
A imImageCannotRemove() 0 3 1
A imThumbCannotRemove() 0 3 1
A imDescCannotCopyBase() 0 3 1
A imImageCannotMoveBase() 0 3 1
A imImageSizeExists() 0 3 1
A imDescCannotFind() 0 3 1
A imThumbAlreadyExistsHere() 0 3 1
A imWrongInstance() 0 3 1
A imDirThumbCannotRemove() 0 3 1
A imSizesNotSet() 0 3 1
A imThumbCannotGetBaseImage() 0 3 1
A imImageCannotRenameBase() 0 3 1
A imImageCannotCopyBase() 0 3 1
A imThumbCannotCopyBase() 0 3 1
A imImageCannotCreateEmpty() 0 3 1
A imImageCannotGetSize() 0 3 1
A imCannotCreateFromResource() 0 3 1
A imImageCannotResize() 0 3 1
A imThumbCannotStoreTemporaryImage() 0 3 1
A imImageCannotResample() 0 3 1
A imImageMagicLibNotPresent() 0 3 1
A imGdLibNotPresent() 0 3 1
A imThumbCannotLoadTemporaryImage() 0 3 1
A imCannotSaveResource() 0 3 1

How to fix   Complexity   

Complex Class

Complex classes like Translations 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 Translations, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
namespace kalanis\kw_images;
4
5
6
use kalanis\kw_images\Interfaces\IIMTranslations;
7
8
9
/**
10
 * Class Translations
11
 * @package kalanis\kw_images
12
 */
13
class Translations implements IIMTranslations
14
{
15
    /**
16
     * @return string
17
     * @codeCoverageIgnore
18
     */
19
    public function imGdLibNotPresent(): string
20
    {
21
        return 'GD2 library is not present!';
22
    }
23
24
    /**
25
     * @return string
26
     * @codeCoverageIgnore
27
     */
28
    public function imImageMagicLibNotPresent(): string
29
    {
30
        return 'ImageMagic not installed or too old!';
31
    }
32
33
    /**
34
     * @return string
35
     * @codeCoverageIgnore
36
     */
37
    public function imCannotCreateFromResource(): string
38
    {
39
        return 'Cannot create image from resource!';
40
    }
41
42
    /**
43
     * @return string
44
     * @codeCoverageIgnore
45
     */
46
    public function imCannotSaveResource(): string
47
    {
48
        return 'Cannot save image resource!';
49
    }
50
51 2
    public function imUnknownType(string $type): string
52
    {
53 2
        return sprintf('Unknown type *%s*', $type);
54
    }
55
56 1
    public function imWrongInstance(string $instance): string
57
    {
58 1
        return sprintf('Wrong instance of *%s*, must be instance of \kalanis\kw_images\Graphics\Format\AFormat', $instance);
59
    }
60
61 1
    public function imWrongMime(string $mime): string
62
    {
63 1
        return sprintf('Wrong file mime type - got *%s*', $mime);
64
    }
65
66 2
    public function imSizesNotSet(): string
67
    {
68 2
        return 'Sizes to compare are not set.';
69
    }
70
71
    /**
72
     * @return string
73
     * @codeCoverageIgnore
74
     */
75
    public function imImageCannotResize(): string
76
    {
77
        return 'Image cannot be resized!';
78
    }
79
80
    /**
81
     * @return string
82
     * @codeCoverageIgnore
83
     */
84
    public function imImageCannotResample(): string
85
    {
86
        return 'Image cannot be resampled!';
87
    }
88
89
    /**
90
     * @return string
91
     * @codeCoverageIgnore
92
     */
93
    public function imImageCannotCreateEmpty(): string
94
    {
95
        return 'Cannot create empty image!';
96
    }
97
98
    /**
99
     * @return string
100
     * @codeCoverageIgnore
101
     */
102
    public function imImageCannotGetSize(): string
103
    {
104
        return 'Cannot get image size!';
105
    }
106
107 1
    public function imImageLoadFirst(): string
108
    {
109 1
        return 'You must load image first!';
110
    }
111
112 3
    public function imDescCannotRemove(): string
113
    {
114 3
        return 'Cannot remove description!';
115
    }
116
117 4
    public function imDescCannotFind(): string
118
    {
119 4
        return 'Cannot find that description.';
120
    }
121
122 4
    public function imDescAlreadyExistsHere(): string
123
    {
124 4
        return 'Description with the same name already exists here.';
125
    }
126
127 4
    public function imDescCannotRemoveOld(): string
128
    {
129 4
        return 'Cannot remove old description.';
130
    }
131
132 2
    public function imDescCannotCopyBase(): string
133
    {
134 2
        return 'Cannot copy base description.';
135
    }
136
137 2
    public function imDescCannotMoveBase(): string
138
    {
139 2
        return 'Cannot move base description.';
140
    }
141
142 2
    public function imDescCannotRenameBase(): string
143
    {
144 2
        return 'Cannot rename base description.';
145
    }
146
147 2
    public function imDirThumbCannotRemove(): string
148
    {
149 2
        return 'Cannot remove dir thumb!';
150
    }
151
152 1
    public function imDirThumbCannotRemoveCurrent(): string
153
    {
154 1
        return 'Cannot remove current thumb!';
155
    }
156
157 1
    public function imImageSizeExists(): string
158
    {
159 1
        return 'Cannot read file size. Exists?';
160
    }
161
162 1
    public function imImageSizeTooLarge(): string
163
    {
164 1
        return 'This image is too large to use.';
165
    }
166
167 10
    public function imImageCannotFind(): string
168
    {
169 10
        return 'Cannot find that image.';
170
    }
171
172 5
    public function imImageCannotRemove(): string
173
    {
174 5
        return 'Cannot remove image.';
175
    }
176
177 10
    public function imImageAlreadyExistsHere(): string
178
    {
179 10
        return 'Image with the same name already exists here.';
180
    }
181
182 10
    public function imImageCannotRemoveOld(): string
183
    {
184 10
        return 'Cannot remove old image.';
185
    }
186
187 4
    public function imImageCannotCopyBase(): string
188
    {
189 4
        return 'Cannot copy base image.';
190
    }
191
192 4
    public function imImageCannotMoveBase(): string
193
    {
194 4
        return 'Cannot move base image.';
195
    }
196
197 4
    public function imImageCannotRenameBase(): string
198
    {
199 4
        return 'Cannot rename base image.';
200
    }
201
202 7
    public function imThumbCannotFind(): string
203
    {
204 7
        return 'Cannot find that thumb.';
205
    }
206
207 5
    public function imThumbCannotRemove(): string
208
    {
209 5
        return 'Cannot remove thumb!';
210
    }
211
212 7
    public function imThumbAlreadyExistsHere(): string
213
    {
214 7
        return 'Thumb with the same name already exists here.';
215
    }
216
217 7
    public function imThumbCannotRemoveOld(): string
218
    {
219 7
        return 'Cannot remove old thumb.';
220
    }
221
222 1
    public function imThumbCannotGetBaseImage(): string
223
    {
224 1
        return 'Cannot get base image.';
225
    }
226
227
    /**
228
     * @return string
229
     * @codeCoverageIgnore failed local volume
230
     */
231
    public function imThumbCannotStoreTemporaryImage(): string
232
    {
233
        return 'Cannot store temporary image.';
234
    }
235
236
    /**
237
     * @return string
238
     * @codeCoverageIgnore failed local volume
239
     */
240
    public function imThumbCannotLoadTemporaryImage(): string
241
    {
242
        return 'Cannot load temporary image.';
243
    }
244
245 3
    public function imThumbCannotCopyBase(): string
246
    {
247 3
        return 'Cannot copy base thumb.';
248
    }
249
250 3
    public function imThumbCannotMoveBase(): string
251
    {
252 3
        return 'Cannot move base thumb.';
253
    }
254
255 3
    public function imThumbCannotRenameBase(): string
256
    {
257 3
        return 'Cannot rename base thumb.';
258
    }
259
}
260