1919 *
2020 * @author Fabien Potencier <[email protected] > 2121 * @author Саша Стаменковић <[email protected] > 22+ * @author Dany Maillard <[email protected] > 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,71 @@ 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+ * @return $this
145+ */
146+ public function setCrossingChars (string $ cross , string $ topLeft , string $ topMid , string $ topRight , string $ midRight , string $ bottomRight , string $ bottomMid , string $ bottomLeft , string $ midLeft ): self
147+ {
148+ $ this ->crossingChar = $ cross ;
149+ $ this ->crossingTopLeftChar = $ topLeft ;
150+ $ this ->crossingTopMidChar = $ topMid ;
151+ $ this ->crossingTopRightChar = $ topRight ;
152+ $ this ->crossingMidRightChar = $ midRight ;
153+ $ this ->crossingBottomRightChar = $ bottomRight ;
154+ $ this ->crossingBottomMidChar = $ bottomMid ;
155+ $ this ->crossingBottomLeftChar = $ bottomLeft ;
156+ $ this ->crossingMidLeftChar = $ midLeft ;
157+
158+ return $ this ;
159+ }
160+
161+ /**
162+ * Sets default crossing character used for each cross.
163+ *
164+ * @see {@link setCrossingChars()} for setting each crossing individually.
165+ */
166+ public function setDefaultCrossingChar (string $ char ): self
167+ {
168+ return $ this ->setCrossingChars ($ char , $ char , $ char , $ char , $ char , $ char , $ char , $ char , $ char );
169+ }
170+
111171 /**
112172 * Sets crossing character.
113173 *
114174 * @param string $crossingChar
115175 *
116176 * @return $this
177+ *
178+ * @deprecated since Symfony 4.1, to be removed in 5.0. Use {@link setDefaultCrossingChar()} instead.
117179 */
118180 public function setCrossingChar ($ crossingChar )
119181 {
120- $ this -> crossingChar = $ crossingChar ;
182+ @ trigger_error ( sprintf ( ' Method %s() is deprecated since Symfony 4.1 and will be removed in 5.0. Use setDefaultCrossingChar() instead. ' , __METHOD__ ), E_USER_DEPRECATED ) ;
121183
122- return $ this ;
184+ return $ this -> setDefaultCrossingChar ( $ crossingChar ) ;
123185 }
124186
125187 /**
@@ -132,6 +194,46 @@ public function getCrossingChar()
132194 return $ this ->crossingChar ;
133195 }
134196
197+ public function getCrossingTopRightChar (): string
198+ {
199+ return $ this ->crossingTopRightChar ;
200+ }
201+
202+ public function getCrossingTopMidChar (): string
203+ {
204+ return $ this ->crossingTopMidChar ;
205+ }
206+
207+ public function getCrossingTopLeftChar (): string
208+ {
209+ return $ this ->crossingTopLeftChar ;
210+ }
211+
212+ public function getCrossingMidRightChar (): string
213+ {
214+ return $ this ->crossingMidRightChar ;
215+ }
216+
217+ public function getCrossingBottomRightChar (): string
218+ {
219+ return $ this ->crossingBottomRightChar ;
220+ }
221+
222+ public function getCrossingBottomMidChar (): string
223+ {
224+ return $ this ->crossingBottomMidChar ;
225+ }
226+
227+ public function getCrossingBottomLeftChar (): string
228+ {
229+ return $ this ->crossingBottomLeftChar ;
230+ }
231+
232+ public function getCrossingMidLeftChar (): string
233+ {
234+ return $ this ->crossingMidLeftChar ;
235+ }
236+
135237 /**
136238 * Sets header cell format.
137239 *
0 commit comments