4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Console\Helper;
14 use Symfony\Component\Console\Exception\InvalidArgumentException;
15 use Symfony\Component\Console\Exception\LogicException;
18 * Defines the styles for a Table.
20 * @author Fabien Potencier <fabien@symfony.com>
21 * @author Саша Стаменковић <umpirsky@gmail.com>
25 private $paddingChar = ' ';
26 private $horizontalBorderChar = '-';
27 private $verticalBorderChar = '|';
28 private $crossingChar = '+';
29 private $cellHeaderFormat = '<info>%s</info>';
30 private $cellRowFormat = '%s';
31 private $cellRowContentFormat = ' %s ';
32 private $borderFormat = '%s';
33 private $padType = STR_PAD_RIGHT;
36 * Sets padding character, used for cell padding.
38 * @param string $paddingChar
42 public function setPaddingChar($paddingChar)
45 throw new LogicException('The padding char must not be empty');
48 $this->paddingChar = $paddingChar;
54 * Gets padding character, used for cell padding.
58 public function getPaddingChar()
60 return $this->paddingChar;
64 * Sets horizontal border character.
66 * @param string $horizontalBorderChar
70 public function setHorizontalBorderChar($horizontalBorderChar)
72 $this->horizontalBorderChar = $horizontalBorderChar;
78 * Gets horizontal border character.
82 public function getHorizontalBorderChar()
84 return $this->horizontalBorderChar;
88 * Sets vertical border character.
90 * @param string $verticalBorderChar
94 public function setVerticalBorderChar($verticalBorderChar)
96 $this->verticalBorderChar = $verticalBorderChar;
102 * Gets vertical border character.
106 public function getVerticalBorderChar()
108 return $this->verticalBorderChar;
112 * Sets crossing character.
114 * @param string $crossingChar
118 public function setCrossingChar($crossingChar)
120 $this->crossingChar = $crossingChar;
126 * Gets crossing character.
128 * @return string $crossingChar
130 public function getCrossingChar()
132 return $this->crossingChar;
136 * Sets header cell format.
138 * @param string $cellHeaderFormat
142 public function setCellHeaderFormat($cellHeaderFormat)
144 $this->cellHeaderFormat = $cellHeaderFormat;
150 * Gets header cell format.
154 public function getCellHeaderFormat()
156 return $this->cellHeaderFormat;
160 * Sets row cell format.
162 * @param string $cellRowFormat
166 public function setCellRowFormat($cellRowFormat)
168 $this->cellRowFormat = $cellRowFormat;
174 * Gets row cell format.
178 public function getCellRowFormat()
180 return $this->cellRowFormat;
184 * Sets row cell content format.
186 * @param string $cellRowContentFormat
190 public function setCellRowContentFormat($cellRowContentFormat)
192 $this->cellRowContentFormat = $cellRowContentFormat;
198 * Gets row cell content format.
202 public function getCellRowContentFormat()
204 return $this->cellRowContentFormat;
208 * Sets table border format.
210 * @param string $borderFormat
214 public function setBorderFormat($borderFormat)
216 $this->borderFormat = $borderFormat;
222 * Gets table border format.
226 public function getBorderFormat()
228 return $this->borderFormat;
232 * Sets cell padding type.
234 * @param int $padType STR_PAD_*
238 public function setPadType($padType)
240 if (!\in_array($padType, array(STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH), true)) {
241 throw new InvalidArgumentException('Invalid padding type. Expected one of (STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH).');
244 $this->padType = $padType;
250 * Gets cell padding type.
254 public function getPadType()
256 return $this->padType;