19
19
*
20
20
* @author Fabien Potencier <fabien@symfony.com>
21
21
* @author Саша Стаменковић <umpirsky@gmail.com>
22
+ * @author Dany Maillard <danymaillard93b@gmail.com>
22
23
*/
23
24
class TableStyle
24
25
{
25
26
private $ paddingChar = ' ' ;
26
27
private $ horizontalBorderChar = '- ' ;
27
28
private $ verticalBorderChar = '| ' ;
28
29
private $ crossingChar = '+ ' ;
30
+ private $ crossingTopRightChar = '+ ' ;
31
+ private $ crossingTopMidChar = '+ ' ;
32
+ private $ crossingTopLeftChar = '+ ' ;
33
+ private $ crossingMidRightChar = '+ ' ;
34
+ private $ crossingBottomRightChar = '+ ' ;
35
+ private $ crossingBottomMidChar = '+ ' ;
36
+ private $ crossingBottomLeftChar = '+ ' ;
37
+ private $ crossingMidLeftChar = '+ ' ;
29
38
private $ cellHeaderFormat = '<info>%s</info> ' ;
30
39
private $ cellRowFormat = '%s ' ;
31
40
private $ cellRowContentFormat = ' %s ' ;
@@ -108,18 +117,69 @@ public function getVerticalBorderChar()
108
117
return $ this ->verticalBorderChar ;
109
118
}
110
119
120
+ /**
121
+ * Sets crossing characters.
122
+ *
123
+ * Example:
124
+ * <code>
125
+ * 1---------------2-----------------------2------------------3
126
+ * | ISBN | Title | Author |
127
+ * 8---------------0-----------------------0------------------4
128
+ * | 99921-58-10-7 | Divine Comedy | Dante Alighieri |
129
+ * | 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens |
130
+ * | 960-425-059-0 | The Lord of the Rings | J. R. R. Tolkien |
131
+ * 7---------------6-----------------------6------------------5
132
+ * </code>
133
+ *
134
+ * @param string $cross Crossing char (see #0 of example)
135
+ * @param string $topLeft Top left char (see #1 of example)
136
+ * @param string $topMid Top mid char (see #2 of example)
137
+ * @param string $topRight Top right char (see #3 of example)
138
+ * @param string $midRight Mid right char (see #4 of example)
139
+ * @param string $bottomRight Bottom right char (see #5 of example)
140
+ * @param string $bottomMid Bottom mid char (see #6 of example)
141
+ * @param string $bottomLeft Bottom left char (see #7 of example)
142
+ * @param string $midLeft Mid left char (see #8 of example)
143
+ */
144
+ public function setCrossingChars (string $ cross , string $ topLeft , string $ topMid , string $ topRight , string $ midRight , string $ bottomRight , string $ bottomMid , string $ bottomLeft , string $ midLeft ): self
145
+ {
146
+ $ this ->crossingChar = $ cross ;
147
+ $ this ->crossingTopLeftChar = $ topLeft ;
148
+ $ this ->crossingTopMidChar = $ topMid ;
149
+ $ this ->crossingTopRightChar = $ topRight ;
150
+ $ this ->crossingMidRightChar = $ midRight ;
151
+ $ this ->crossingBottomRightChar = $ bottomRight ;
152
+ $ this ->crossingBottomMidChar = $ bottomMid ;
153
+ $ this ->crossingBottomLeftChar = $ bottomLeft ;
154
+ $ this ->crossingMidLeftChar = $ midLeft ;
155
+
156
+ return $ this ;
157
+ }
158
+
159
+ /**
160
+ * Sets default crossing character used for each cross.
161
+ *
162
+ * @see {@link setCrossingChars()} for setting each crossing individually.
163
+ */
164
+ public function setDefaultCrossingChar (string $ char ): self
165
+ {
166
+ return $ this ->setCrossingChars ($ char , $ char , $ char , $ char , $ char , $ char , $ char , $ char , $ char );
167
+ }
168
+
111
169
/**
112
170
* Sets crossing character.
113
171
*
114
172
* @param string $crossingChar
115
173
*
116
174
* @return $this
175
+ *
176
+ * @deprecated since Symfony 4.1. Use {@link setDefaultCrossingChar()} instead.
117
177
*/
118
178
public function setCrossingChar ($ crossingChar )
119
179
{
120
- $ this -> crossingChar = $ crossingChar ;
180
+ @ trigger_error ( sprintf ( ' Method %s() is deprecated since Symfony 4.1. Use setDefaultCrossingChar() instead. ' , __METHOD__ ), E_USER_DEPRECATED ) ;
121
181
122
- return $ this ;
182
+ return $ this -> setDefaultCrossingChar ( $ crossingChar ) ;
123
183
}
124
184
125
185
/**
@@ -132,6 +192,26 @@ public function getCrossingChar()
132
192
return $ this ->crossingChar ;
133
193
}
134
194
195
+ /**
196
+ * Gets crossing characters.
197
+ *
198
+ * @internal
199
+ */
200
+ public function getCrossingChars (): array
201
+ {
202
+ return array (
203
+ $ this ->crossingChar ,
204
+ $ this ->crossingTopLeftChar ,
205
+ $ this ->crossingTopMidChar ,
206
+ $ this ->crossingTopRightChar ,
207
+ $ this ->crossingMidRightChar ,
208
+ $ this ->crossingBottomRightChar ,
209
+ $ this ->crossingBottomMidChar ,
210
+ $ this ->crossingBottomLeftChar ,
211
+ $ this ->crossingMidLeftChar ,
212
+ );
213
+ }
214
+
135
215
/**
136
216
* Sets header cell format.
137
217
*
0 commit comments