1919 *
2020 * @author Fabien Potencier <fabien@symfony.com>
2121 * @author Саша Стаменковић <umpirsky@gmail.com>
22+ * @author Dany Maillard <danymaillard93b@gmail.com>
2223 */
2324class TableStyle
2425{
2526 private $ paddingChar = ' ' ;
2627 private $ horizontalBorderChar = '- ' ;
2728 private $ verticalBorderChar = '| ' ;
2829 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 = '+ ' ;
2938 private $ cellHeaderFormat = '<info>%s</info> ' ;
3039 private $ cellRowFormat = '%s ' ;
3140 private $ cellRowContentFormat = ' %s ' ;
@@ -108,18 +117,69 @@ public function getVerticalBorderChar()
108117 return $ this ->verticalBorderChar ;
109118 }
110119
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+
111169 /**
112170 * Sets crossing character.
113171 *
114172 * @param string $crossingChar
115173 *
116174 * @return $this
175+ *
176+ * @deprecated since Symfony 4.1. Use {@link setDefaultCrossingChar()} instead.
117177 */
118178 public function setCrossingChar ($ crossingChar )
119179 {
120- $ this -> crossingChar = $ crossingChar ;
180+ @ trigger_error ( sprintf ( ' Method %s() is deprecated since Symfony 4.1. Use setDefaultCrossingChar() instead. ' , __METHOD__ ), E_USER_DEPRECATED ) ;
121181
122- return $ this ;
182+ return $ this -> setDefaultCrossingChar ( $ crossingChar ) ;
123183 }
124184
125185 /**
@@ -132,6 +192,26 @@ public function getCrossingChar()
132192 return $ this ->crossingChar ;
133193 }
134194
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+
135215 /**
136216 * Sets header cell format.
137217 *
0 commit comments