Completed
Push — develop_3.0 ( c4e25a...238756 )
by Adrien
02:29
created

StyleBuilder::setBackgroundColor()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Box\Spout\Writer\Common\Creator\Style;
4
5
use Box\Spout\Writer\Common\Entity\Style\Border;
6
use Box\Spout\Writer\Common\Entity\Style\Style;
7
8
/**
9
 * Class StyleBuilder
10
 * Builder to create new styles
11
 *
12
 * @package Box\Spout\Writer\Common\Creator\Style
13
 */
14
class StyleBuilder
15
{
16
    /** @var Style Style to be created */
17
    protected $style;
18
19
    /**
20
     *
21
     */
22 118
    public function __construct()
23
    {
24 118
        $this->style = new Style();
25 118
    }
26
27
    /**
28
     * Makes the font bold.
29
     *
30
     * @api
31
     * @return StyleBuilder
32
     */
33 16
    public function setFontBold()
34
    {
35 16
        $this->style->setFontBold();
36 16
        return $this;
37
    }
38
39
    /**
40
     * Makes the font italic.
41
     *
42
     * @api
43
     * @return StyleBuilder
44
     */
45 4
    public function setFontItalic()
46
    {
47 4
        $this->style->setFontItalic();
48 4
        return $this;
49
    }
50
51
    /**
52
     * Makes the font underlined.
53
     *
54
     * @api
55
     * @return StyleBuilder
56
     */
57 6
    public function setFontUnderline()
58
    {
59 6
        $this->style->setFontUnderline();
60 6
        return $this;
61
    }
62
63
    /**
64
     * Makes the font struck through.
65
     *
66
     * @api
67
     * @return StyleBuilder
68
     */
69 4
    public function setFontStrikethrough()
70
    {
71 4
        $this->style->setFontStrikethrough();
72 4
        return $this;
73
    }
74
75
    /**
76
     * Sets the font size.
77
     *
78
     * @api
79
     * @param int $fontSize Font size, in pixels
80
     * @return StyleBuilder
81
     */
82 57
    public function setFontSize($fontSize)
83
    {
84 57
        $this->style->setFontSize($fontSize);
85 57
        return $this;
86
    }
87
88
    /**
89
     * Sets the font color.
90
     *
91
     * @api
92
     * @param string $fontColor ARGB color (@see Color)
93
     * @return StyleBuilder
94
     */
95 2
    public function setFontColor($fontColor)
96
    {
97 2
        $this->style->setFontColor($fontColor);
98 2
        return $this;
99
    }
100
101
    /**
102
     * Sets the font name.
103
     *
104
     * @api
105
     * @param string $fontName Name of the font to use
106
     * @return StyleBuilder
107
     */
108 54
    public function setFontName($fontName)
109
    {
110 54
        $this->style->setFontName($fontName);
111 54
        return $this;
112
    }
113
114
    /**
115
     * Makes the text wrap in the cell if requested
116
     *
117
     * @api
118
     * @param bool $shouldWrap Should the text be wrapped
119
     * @return StyleBuilder
120
     */
121 5
    public function setShouldWrapText($shouldWrap = true)
122
    {
123 5
        $this->style->setShouldWrapText($shouldWrap);
124 5
        return $this;
125
    }
126
127
    /**
128
     * Set a border
129
     *
130
     * @param Border $border
131
     * @return $this
132
     */
133 8
    public function setBorder(Border $border)
134
    {
135 8
        $this->style->setBorder($border);
136 8
        return $this;
137
    }
138
139
    /**
140
     *  Sets a background color
141
     *
142
     * @api
143
     * @param string $color ARGB color (@see Color)
144
     * @return StyleBuilder
145
     */
146 6
    public function setBackgroundColor($color)
147
    {
148 6
        $this->style->setBackgroundColor($color);
149 6
        return $this;
150
    }
151
152
    /**
153
     * Returns the configured style. The style is cached and can be reused.
154
     *
155
     * @api
156
     * @return Style
157
     */
158 118
    public function build()
159
    {
160 118
        return $this->style;
161
    }
162
}
163