Failed Conditions
Pull Request — develop_3.0 (#594)
by
unknown
04:29
created

Style   A

Complexity

Total Complexity 36

Size/Duplication

Total Lines 410
Duplicated Lines 0 %

Coupling/Cohesion

Components 5
Dependencies 0

Test Coverage

Coverage 94.12%

Importance

Changes 0
Metric Value
wmc 36
lcom 5
cbo 0
dl 0
loc 410
ccs 96
cts 102
cp 0.9412
rs 9.52
c 0
b 0
f 0

36 Methods

Rating   Name   Duplication   Size   Complexity  
A getId() 0 4 1
A setId() 0 6 1
A getBorder() 0 4 1
A setBorder() 0 7 1
A getNumberFormat() 0 4 1
A setNumberFormat() 0 7 1
A shouldApplyBorder() 0 4 1
A shouldApplyNumberFormat() 0 4 1
A isFontBold() 0 4 1
A setFontBold() 0 8 1
A hasSetFontBold() 0 4 1
A isFontItalic() 0 4 1
A setFontItalic() 0 8 1
A hasSetFontItalic() 0 4 1
A isFontUnderline() 0 4 1
A setFontUnderline() 0 8 1
A hasSetFontUnderline() 0 4 1
A isFontStrikethrough() 0 4 1
A setFontStrikethrough() 0 8 1
A hasSetFontStrikethrough() 0 4 1
A getFontSize() 0 4 1
A setFontSize() 0 8 1
A hasSetFontSize() 0 4 1
A getFontColor() 0 4 1
A setFontColor() 0 8 1
A hasSetFontColor() 0 4 1
A getFontName() 0 4 1
A setFontName() 0 8 1
A hasSetFontName() 0 4 1
A shouldWrapText() 0 4 1
A setShouldWrapText() 0 7 1
A hasSetWrapText() 0 4 1
A shouldApplyFont() 0 4 1
A setBackgroundColor() 0 7 1
A getBackgroundColor() 0 4 1
A shouldApplyBackgroundColor() 0 4 1
1
<?php
2
3
namespace Box\Spout\Common\Entity\Style;
4
5
/**
6
 * Class Style
7
 * Represents a style to be applied to a cell
8
 */
9
class Style
10
{
11
    /** Default font values */
12
    const DEFAULT_FONT_SIZE = 11;
13
    const DEFAULT_FONT_COLOR = Color::BLACK;
14
    const DEFAULT_FONT_NAME = 'Arial';
15
16
    /** @var int|null Style ID */
17
    private $id;
18
19
    /** @var bool Whether the font should be bold */
20
    private $fontBold = false;
21
    /** @var bool Whether the bold property was set */
22
    private $hasSetFontBold = false;
23
24
    /** @var bool Whether the font should be italic */
25
    private $fontItalic = false;
26
    /** @var bool Whether the italic property was set */
27
    private $hasSetFontItalic = false;
28
29
    /** @var bool Whether the font should be underlined */
30
    private $fontUnderline = false;
31
    /** @var bool Whether the underline property was set */
32
    private $hasSetFontUnderline = false;
33
34
    /** @var bool Whether the font should be struck through */
35
    private $fontStrikethrough = false;
36
    /** @var bool Whether the strikethrough property was set */
37
    private $hasSetFontStrikethrough = false;
38
39
    /** @var int Font size */
40
    private $fontSize = self::DEFAULT_FONT_SIZE;
41
    /** @var bool Whether the font size property was set */
42
    private $hasSetFontSize = false;
43
44
    /** @var string Font color */
45
    private $fontColor = self::DEFAULT_FONT_COLOR;
46
    /** @var bool Whether the font color property was set */
47
    private $hasSetFontColor = false;
48
49
    /** @var string Font name */
50
    private $fontName = self::DEFAULT_FONT_NAME;
51
    /** @var bool Whether the font name property was set */
52
    private $hasSetFontName = false;
53
54
    /** @var bool Whether specific font properties should be applied */
55
    private $shouldApplyFont = false;
56
57
    /** @var bool Whether the text should wrap in the cell (useful for long or multi-lines text) */
58
    private $shouldWrapText = false;
59
    /** @var bool Whether the wrap text property was set */
60
    private $hasSetWrapText = false;
61
62
    /** @var Border */
63
    private $border;
64
65
    /** @var bool Whether border properties should be applied */
66
    private $shouldApplyBorder = false;
67
68
    /** @var string Background color */
69
    private $backgroundColor;
70
71
    /** @var bool */
72
    private $hasSetBackgroundColor = false;
73
74
    private $numberFormat;
75
    /** @var bool Whether border properties should be applied */
76
    private $shouldApplyNumberFormat = false;
77
78
79
    /**
80
     * @return int|null
81
     */
82 77
    public function getId()
83
    {
84 77
        return $this->id;
85
    }
86
87
    /**
88
     * @param int $id
89
     * @return Style
90
     */
91 77
    public function setId($id)
92
    {
93 77
        $this->id = $id;
94
95 77
        return $this;
96
    }
97
98
    /**
99
     * @return Border
100
     */
101 65
    public function getBorder()
102
    {
103 65
        return $this->border;
104
    }
105
106
    /**
107
     * @param Border $border
108
     * @return Style
109
     */
110 4
    public function setBorder(Border $border)
111
    {
112 4
        $this->shouldApplyBorder = true;
113 4
        $this->border = $border;
114
115 4
        return $this;
116
    }
117
118
    /**
119
     * @return NumberFormat
120
     */
121
    public function getNumberFormat()
122
    {
123
        return $this->numberFormat;
124
    }
125
126
    /**
127
     * @param NumberFormat $format
128
     * @return Style
129
     */
130
    public function setNumberFormat(NumberFormat $format)
131
    {
132
        $this->shouldApplyNumberFormat = true;
133
        $this->numberFormat = $format;
134
135
        return $this;
136
    }
137
138
    /**
139
     * @return bool
140
     */
141 76
    public function shouldApplyBorder()
142
    {
143 76
        return $this->shouldApplyBorder;
144
    }
145
    /**
146
     * @return bool
147
     */
148 36
    public function shouldApplyNumberFormat()
149
    {
150 36
        return $this->shouldApplyNumberFormat;
151
    }
152
153
    /**
154
     * @return bool
155
     */
156 67
    public function isFontBold()
157
    {
158 67
        return $this->fontBold;
159
    }
160
161
    /**
162
     * @return Style
163
     */
164 14
    public function setFontBold()
165
    {
166 14
        $this->fontBold = true;
167 14
        $this->hasSetFontBold = true;
168 14
        $this->shouldApplyFont = true;
169
170 14
        return $this;
171
    }
172
173
    /**
174
     * @return bool
175
     */
176 64
    public function hasSetFontBold()
177
    {
178 64
        return $this->hasSetFontBold;
179
    }
180
181
    /**
182
     * @return bool
183
     */
184 67
    public function isFontItalic()
185
    {
186 67
        return $this->fontItalic;
187
    }
188
189
    /**
190
     * @return Style
191
     */
192 6
    public function setFontItalic()
193
    {
194 6
        $this->fontItalic = true;
195 6
        $this->hasSetFontItalic = true;
196 6
        $this->shouldApplyFont = true;
197
198 6
        return $this;
199
    }
200
201
    /**
202
     * @return bool
203
     */
204 64
    public function hasSetFontItalic()
205
    {
206 64
        return $this->hasSetFontItalic;
207
    }
208
209
    /**
210
     * @return bool
211
     */
212 67
    public function isFontUnderline()
213
    {
214 67
        return $this->fontUnderline;
215
    }
216
217
    /**
218
     * @return Style
219
     */
220 7
    public function setFontUnderline()
221
    {
222 7
        $this->fontUnderline = true;
223 7
        $this->hasSetFontUnderline = true;
224 7
        $this->shouldApplyFont = true;
225
226 7
        return $this;
227
    }
228
229
    /**
230
     * @return bool
231
     */
232 64
    public function hasSetFontUnderline()
233
    {
234 64
        return $this->hasSetFontUnderline;
235
    }
236
237
    /**
238
     * @return bool
239
     */
240 67
    public function isFontStrikethrough()
241
    {
242 67
        return $this->fontStrikethrough;
243
    }
244
245
    /**
246
     * @return Style
247
     */
248 4
    public function setFontStrikethrough()
249
    {
250 4
        $this->fontStrikethrough = true;
251 4
        $this->hasSetFontStrikethrough = true;
252 4
        $this->shouldApplyFont = true;
253
254 4
        return $this;
255
    }
256
257
    /**
258
     * @return bool
259
     */
260 64
    public function hasSetFontStrikethrough()
261
    {
262 64
        return $this->hasSetFontStrikethrough;
263
    }
264
265
    /**
266
     * @return int
267
     */
268 69
    public function getFontSize()
269
    {
270 69
        return $this->fontSize;
271
    }
272
273
    /**
274
     * @param int $fontSize Font size, in pixels
275
     * @return Style
276
     */
277 44
    public function setFontSize($fontSize)
278
    {
279 44
        $this->fontSize = $fontSize;
280 44
        $this->hasSetFontSize = true;
281 44
        $this->shouldApplyFont = true;
282
283 44
        return $this;
284
    }
285
286
    /**
287
     * @return bool
288
     */
289 64
    public function hasSetFontSize()
290
    {
291 64
        return $this->hasSetFontSize;
292
    }
293
294
    /**
295
     * @return string
296
     */
297 69
    public function getFontColor()
298
    {
299 69
        return $this->fontColor;
300
    }
301
302
    /**
303
     * Sets the font color.
304
     *
305
     * @param string $fontColor ARGB color (@see Color)
306
     * @return Style
307
     */
308 3
    public function setFontColor($fontColor)
309
    {
310 3
        $this->fontColor = $fontColor;
311 3
        $this->hasSetFontColor = true;
312 3
        $this->shouldApplyFont = true;
313
314 3
        return $this;
315
    }
316
317
    /**
318
     * @return bool
319
     */
320 64
    public function hasSetFontColor()
321
    {
322 64
        return $this->hasSetFontColor;
323
    }
324
325
    /**
326
     * @return string
327
     */
328 73
    public function getFontName()
329
    {
330 73
        return $this->fontName;
331
    }
332
333
    /**
334
     * @param string $fontName Name of the font to use
335
     * @return Style
336
     */
337 43
    public function setFontName($fontName)
338
    {
339 43
        $this->fontName = $fontName;
340 43
        $this->hasSetFontName = true;
341 43
        $this->shouldApplyFont = true;
342
343 43
        return $this;
344
    }
345
346
    /**
347
     * @return bool
348
     */
349 64
    public function hasSetFontName()
350
    {
351 64
        return $this->hasSetFontName;
352
    }
353
354
    /**
355
     * @return bool
356
     */
357 71
    public function shouldWrapText()
358
    {
359 71
        return $this->shouldWrapText;
360
    }
361
362
    /**
363
     * @param bool $shouldWrap Should the text be wrapped
364
     * @return Style
365
     */
366 8
    public function setShouldWrapText($shouldWrap = true)
367
    {
368 8
        $this->shouldWrapText = $shouldWrap;
369 8
        $this->hasSetWrapText = true;
370
371 8
        return $this;
372
    }
373
374
    /**
375
     * @return bool
376
     */
377 66
    public function hasSetWrapText()
378
    {
379 66
        return $this->hasSetWrapText;
380
    }
381
382
    /**
383
     * @return bool Whether specific font properties should be applied
384
     */
385 60
    public function shouldApplyFont()
386
    {
387 60
        return $this->shouldApplyFont;
388
    }
389
390
    /**
391
     * Sets the background color
392
     * @param string $color ARGB color (@see Color)
393
     * @return Style
394
     */
395 6
    public function setBackgroundColor($color)
396
    {
397 6
        $this->hasSetBackgroundColor = true;
398 6
        $this->backgroundColor = $color;
399
400 6
        return $this;
401
    }
402
403
    /**
404
     * @return string
405
     */
406 39
    public function getBackgroundColor()
407
    {
408 39
        return $this->backgroundColor;
409
    }
410
411
    /**
412
     * @return bool Whether the background color should be applied
413
     */
414 66
    public function shouldApplyBackgroundColor()
415
    {
416 66
        return $this->hasSetBackgroundColor;
417
    }
418
}
419