1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Box\Spout\Writer\Style; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class StyleBuilder |
7
|
|
|
* Builder to create new styles |
8
|
|
|
* |
9
|
|
|
* @package Box\Spout\Writer\Style |
10
|
|
|
*/ |
11
|
|
|
class StyleBuilder |
12
|
|
|
{ |
13
|
|
|
/** @var Style Style to be created */ |
14
|
|
|
protected $style; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* |
18
|
|
|
*/ |
19
|
303 |
|
public function __construct() |
20
|
|
|
{ |
21
|
303 |
|
$this->style = new Style(); |
22
|
303 |
|
} |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Makes the font bold. |
26
|
|
|
* |
27
|
|
|
* @api |
28
|
|
|
* @return StyleBuilder |
29
|
|
|
*/ |
30
|
36 |
|
public function setFontBold() |
31
|
|
|
{ |
32
|
36 |
|
$this->style->setFontBold(); |
33
|
36 |
|
return $this; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Makes the font italic. |
38
|
|
|
* |
39
|
|
|
* @api |
40
|
|
|
* @return StyleBuilder |
41
|
|
|
*/ |
42
|
12 |
|
public function setFontItalic() |
43
|
|
|
{ |
44
|
12 |
|
$this->style->setFontItalic(); |
45
|
12 |
|
return $this; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Makes the font underlined. |
50
|
|
|
* |
51
|
|
|
* @api |
52
|
|
|
* @return StyleBuilder |
53
|
|
|
*/ |
54
|
18 |
|
public function setFontUnderline() |
55
|
|
|
{ |
56
|
18 |
|
$this->style->setFontUnderline(); |
57
|
18 |
|
return $this; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Makes the font struck through. |
62
|
|
|
* |
63
|
|
|
* @api |
64
|
|
|
* @return StyleBuilder |
65
|
|
|
*/ |
66
|
12 |
|
public function setFontStrikethrough() |
67
|
|
|
{ |
68
|
12 |
|
$this->style->setFontStrikethrough(); |
69
|
12 |
|
return $this; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Sets the font size. |
74
|
|
|
* |
75
|
|
|
* @api |
76
|
|
|
* @param int $fontSize Font size, in pixels |
77
|
|
|
* @return StyleBuilder |
78
|
|
|
*/ |
79
|
126 |
|
public function setFontSize($fontSize) |
80
|
|
|
{ |
81
|
126 |
|
$this->style->setFontSize($fontSize); |
82
|
126 |
|
return $this; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Sets the font color. |
87
|
|
|
* |
88
|
|
|
* @api |
89
|
|
|
* @param string $fontColor ARGB color (@see Color) |
90
|
|
|
* @return StyleBuilder |
91
|
|
|
*/ |
92
|
6 |
|
public function setFontColor($fontColor) |
93
|
|
|
{ |
94
|
6 |
|
$this->style->setFontColor($fontColor); |
95
|
6 |
|
return $this; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* Sets the font name. |
100
|
|
|
* |
101
|
|
|
* @api |
102
|
|
|
* @param string $fontName Name of the font to use |
103
|
|
|
* @return StyleBuilder |
104
|
|
|
*/ |
105
|
120 |
|
public function setFontName($fontName) |
106
|
|
|
{ |
107
|
120 |
|
$this->style->setFontName($fontName); |
108
|
120 |
|
return $this; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* Makes the text wrap in the cell if it's too long or |
113
|
|
|
* on multiple lines. |
114
|
|
|
* |
115
|
|
|
* @api |
116
|
|
|
* @return StyleBuilder |
117
|
|
|
*/ |
118
|
15 |
|
public function setShouldWrapText() |
119
|
|
|
{ |
120
|
15 |
|
$this->style->setShouldWrapText(); |
121
|
15 |
|
return $this; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
public function setNumberFormat($format) |
125
|
|
|
{ |
126
|
|
|
$this->style->setNumberFormat($format); |
127
|
|
|
return $this; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* Returns the configured style. The style is cached and can be reused. |
132
|
|
|
* |
133
|
|
|
* @api |
134
|
|
|
* @return Style |
135
|
|
|
*/ |
136
|
303 |
|
public function build() |
137
|
|
|
{ |
138
|
303 |
|
return $this->style; |
139
|
|
|
} |
140
|
|
|
} |
141
|
|
|
|