Completed
Push — master ( 16a2f9...52312b )
by Adrien
02:04
created

Style::setFormat()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 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
    /** @var string Format */
75
    private $format;
76
77
    /** @var bool */
78
    private $hasSetFormat = false;
79
80
    /**
81
     * @return int|null
82
     */
83 87
    public function getId()
84
    {
85 87
        return $this->id;
86
    }
87
88
    /**
89
     * @param int $id
90
     * @return Style
91
     */
92 87
    public function setId($id)
93
    {
94 87
        $this->id = $id;
95
96 87
        return $this;
97
    }
98
99
    /**
100
     * @return Border
101
     */
102 75
    public function getBorder()
103
    {
104 75
        return $this->border;
105
    }
106
107
    /**
108
     * @param Border $border
109
     * @return Style
110
     */
111 8
    public function setBorder(Border $border)
112
    {
113 8
        $this->shouldApplyBorder = true;
114 8
        $this->border = $border;
115
116 8
        return $this;
117
    }
118
119
    /**
120
     * @return bool
121
     */
122 87
    public function shouldApplyBorder()
123
    {
124 87
        return $this->shouldApplyBorder;
125
    }
126
127
    /**
128
     * @return bool
129
     */
130 77
    public function isFontBold()
131
    {
132 77
        return $this->fontBold;
133
    }
134
135
    /**
136
     * @return Style
137
     */
138 21
    public function setFontBold()
139
    {
140 21
        $this->fontBold = true;
141 21
        $this->hasSetFontBold = true;
142 21
        $this->shouldApplyFont = true;
143
144 21
        return $this;
145
    }
146
147
    /**
148
     * @return bool
149
     */
150 74
    public function hasSetFontBold()
151
    {
152 74
        return $this->hasSetFontBold;
153
    }
154
155
    /**
156
     * @return bool
157
     */
158 77
    public function isFontItalic()
159
    {
160 77
        return $this->fontItalic;
161
    }
162
163
    /**
164
     * @return Style
165
     */
166 7
    public function setFontItalic()
167
    {
168 7
        $this->fontItalic = true;
169 7
        $this->hasSetFontItalic = true;
170 7
        $this->shouldApplyFont = true;
171
172 7
        return $this;
173
    }
174
175
    /**
176
     * @return bool
177
     */
178 74
    public function hasSetFontItalic()
179
    {
180 74
        return $this->hasSetFontItalic;
181
    }
182
183
    /**
184
     * @return bool
185
     */
186 77
    public function isFontUnderline()
187
    {
188 77
        return $this->fontUnderline;
189
    }
190
191
    /**
192
     * @return Style
193
     */
194 7
    public function setFontUnderline()
195
    {
196 7
        $this->fontUnderline = true;
197 7
        $this->hasSetFontUnderline = true;
198 7
        $this->shouldApplyFont = true;
199
200 7
        return $this;
201
    }
202
203
    /**
204
     * @return bool
205
     */
206 74
    public function hasSetFontUnderline()
207
    {
208 74
        return $this->hasSetFontUnderline;
209
    }
210
211
    /**
212
     * @return bool
213
     */
214 77
    public function isFontStrikethrough()
215
    {
216 77
        return $this->fontStrikethrough;
217
    }
218
219
    /**
220
     * @return Style
221
     */
222 4
    public function setFontStrikethrough()
223
    {
224 4
        $this->fontStrikethrough = true;
225 4
        $this->hasSetFontStrikethrough = true;
226 4
        $this->shouldApplyFont = true;
227
228 4
        return $this;
229
    }
230
231
    /**
232
     * @return bool
233
     */
234 74
    public function hasSetFontStrikethrough()
235
    {
236 74
        return $this->hasSetFontStrikethrough;
237
    }
238
239
    /**
240
     * @return int
241
     */
242 79
    public function getFontSize()
243
    {
244 79
        return $this->fontSize;
245
    }
246
247
    /**
248
     * @param int $fontSize Font size, in pixels
249
     * @return Style
250
     */
251 52
    public function setFontSize($fontSize)
252
    {
253 52
        $this->fontSize = $fontSize;
254 52
        $this->hasSetFontSize = true;
255 52
        $this->shouldApplyFont = true;
256
257 52
        return $this;
258
    }
259
260
    /**
261
     * @return bool
262
     */
263 74
    public function hasSetFontSize()
264
    {
265 74
        return $this->hasSetFontSize;
266
    }
267
268
    /**
269
     * @return string
270
     */
271 79
    public function getFontColor()
272
    {
273 79
        return $this->fontColor;
274
    }
275
276
    /**
277
     * Sets the font color.
278
     *
279
     * @param string $fontColor ARGB color (@see Color)
280
     * @return Style
281
     */
282 3
    public function setFontColor($fontColor)
283
    {
284 3
        $this->fontColor = $fontColor;
285 3
        $this->hasSetFontColor = true;
286 3
        $this->shouldApplyFont = true;
287
288 3
        return $this;
289
    }
290
291
    /**
292
     * @return bool
293
     */
294 74
    public function hasSetFontColor()
295
    {
296 74
        return $this->hasSetFontColor;
297
    }
298
299
    /**
300
     * @return string
301
     */
302 83
    public function getFontName()
303
    {
304 83
        return $this->fontName;
305
    }
306
307
    /**
308
     * @param string $fontName Name of the font to use
309
     * @return Style
310
     */
311 50
    public function setFontName($fontName)
312
    {
313 50
        $this->fontName = $fontName;
314 50
        $this->hasSetFontName = true;
315 50
        $this->shouldApplyFont = true;
316
317 50
        return $this;
318
    }
319
320
    /**
321
     * @return bool
322
     */
323 74
    public function hasSetFontName()
324
    {
325 74
        return $this->hasSetFontName;
326
    }
327
328
    /**
329
     * @return bool
330
     */
331 81
    public function shouldWrapText()
332
    {
333 81
        return $this->shouldWrapText;
334
    }
335
336
    /**
337
     * @param bool $shouldWrap Should the text be wrapped
338
     * @return Style
339
     */
340 8
    public function setShouldWrapText($shouldWrap = true)
341
    {
342 8
        $this->shouldWrapText = $shouldWrap;
343 8
        $this->hasSetWrapText = true;
344
345 8
        return $this;
346
    }
347
348
    /**
349
     * @return bool
350
     */
351 76
    public function hasSetWrapText()
352
    {
353 76
        return $this->hasSetWrapText;
354
    }
355
356
    /**
357
     * @return bool Whether specific font properties should be applied
358
     */
359 69
    public function shouldApplyFont()
360
    {
361 69
        return $this->shouldApplyFont;
362
    }
363
364
    /**
365
     * Sets the background color
366
     * @param string $color ARGB color (@see Color)
367
     * @return Style
368
     */
369 7
    public function setBackgroundColor($color)
370
    {
371 7
        $this->hasSetBackgroundColor = true;
372 7
        $this->backgroundColor = $color;
373
374 7
        return $this;
375
    }
376
377
    /**
378
     * @return string
379
     */
380 46
    public function getBackgroundColor()
381
    {
382 46
        return $this->backgroundColor;
383
    }
384
385
    /**
386
     * @return bool Whether the background color should be applied
387
     */
388 76
    public function shouldApplyBackgroundColor()
389
    {
390 76
        return $this->hasSetBackgroundColor;
391
    }
392
393
    /**
394
     * Sets format
395
     * @param string $format
396
     * @return Style
397
     */
398 3
    public function setFormat($format)
399
    {
400 3
        $this->hasSetFormat = true;
401 3
        $this->format = $format;
402
403 3
        return $this;
404
    }
405
406
    /**
407
     * @return string
408
     */
409 84
    public function getFormat()
410
    {
411 84
        return $this->format;
412
    }
413
414
    /**
415
     * @return bool Whether format should be applied
416
     */
417 74
    public function shouldApplyFormat()
418
    {
419 74
        return $this->hasSetFormat;
420
    }
421
}
422