Chris@0: Chris@0: * Chris@0: * For the full copyright and license information, please view the LICENSE Chris@0: * file that was distributed with this source code. Chris@0: */ Chris@0: Chris@0: namespace Symfony\Component\Console\Helper; Chris@0: Chris@0: use Symfony\Component\Console\Exception\InvalidArgumentException; Chris@0: use Symfony\Component\Console\Exception\LogicException; Chris@0: Chris@0: /** Chris@0: * Defines the styles for a Table. Chris@0: * Chris@0: * @author Fabien Potencier Chris@0: * @author Саша Стаменковић Chris@0: */ Chris@0: class TableStyle Chris@0: { Chris@0: private $paddingChar = ' '; Chris@0: private $horizontalBorderChar = '-'; Chris@0: private $verticalBorderChar = '|'; Chris@0: private $crossingChar = '+'; Chris@0: private $cellHeaderFormat = '%s'; Chris@0: private $cellRowFormat = '%s'; Chris@0: private $cellRowContentFormat = ' %s '; Chris@0: private $borderFormat = '%s'; Chris@0: private $padType = STR_PAD_RIGHT; Chris@0: Chris@0: /** Chris@0: * Sets padding character, used for cell padding. Chris@0: * Chris@0: * @param string $paddingChar Chris@0: * Chris@0: * @return $this Chris@0: */ Chris@0: public function setPaddingChar($paddingChar) Chris@0: { Chris@0: if (!$paddingChar) { Chris@0: throw new LogicException('The padding char must not be empty'); Chris@0: } Chris@0: Chris@0: $this->paddingChar = $paddingChar; Chris@0: Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Gets padding character, used for cell padding. Chris@0: * Chris@0: * @return string Chris@0: */ Chris@0: public function getPaddingChar() Chris@0: { Chris@0: return $this->paddingChar; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Sets horizontal border character. Chris@0: * Chris@0: * @param string $horizontalBorderChar Chris@0: * Chris@0: * @return $this Chris@0: */ Chris@0: public function setHorizontalBorderChar($horizontalBorderChar) Chris@0: { Chris@0: $this->horizontalBorderChar = $horizontalBorderChar; Chris@0: Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Gets horizontal border character. Chris@0: * Chris@0: * @return string Chris@0: */ Chris@0: public function getHorizontalBorderChar() Chris@0: { Chris@0: return $this->horizontalBorderChar; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Sets vertical border character. Chris@0: * Chris@0: * @param string $verticalBorderChar Chris@0: * Chris@0: * @return $this Chris@0: */ Chris@0: public function setVerticalBorderChar($verticalBorderChar) Chris@0: { Chris@0: $this->verticalBorderChar = $verticalBorderChar; Chris@0: Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Gets vertical border character. Chris@0: * Chris@0: * @return string Chris@0: */ Chris@0: public function getVerticalBorderChar() Chris@0: { Chris@0: return $this->verticalBorderChar; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Sets crossing character. Chris@0: * Chris@0: * @param string $crossingChar Chris@0: * Chris@0: * @return $this Chris@0: */ Chris@0: public function setCrossingChar($crossingChar) Chris@0: { Chris@0: $this->crossingChar = $crossingChar; Chris@0: Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Gets crossing character. Chris@0: * Chris@17: * @return string Chris@0: */ Chris@0: public function getCrossingChar() Chris@0: { Chris@0: return $this->crossingChar; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Sets header cell format. Chris@0: * Chris@0: * @param string $cellHeaderFormat Chris@0: * Chris@0: * @return $this Chris@0: */ Chris@0: public function setCellHeaderFormat($cellHeaderFormat) Chris@0: { Chris@0: $this->cellHeaderFormat = $cellHeaderFormat; Chris@0: Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Gets header cell format. Chris@0: * Chris@0: * @return string Chris@0: */ Chris@0: public function getCellHeaderFormat() Chris@0: { Chris@0: return $this->cellHeaderFormat; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Sets row cell format. Chris@0: * Chris@0: * @param string $cellRowFormat Chris@0: * Chris@0: * @return $this Chris@0: */ Chris@0: public function setCellRowFormat($cellRowFormat) Chris@0: { Chris@0: $this->cellRowFormat = $cellRowFormat; Chris@0: Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Gets row cell format. Chris@0: * Chris@0: * @return string Chris@0: */ Chris@0: public function getCellRowFormat() Chris@0: { Chris@0: return $this->cellRowFormat; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Sets row cell content format. Chris@0: * Chris@0: * @param string $cellRowContentFormat Chris@0: * Chris@0: * @return $this Chris@0: */ Chris@0: public function setCellRowContentFormat($cellRowContentFormat) Chris@0: { Chris@0: $this->cellRowContentFormat = $cellRowContentFormat; Chris@0: Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Gets row cell content format. Chris@0: * Chris@0: * @return string Chris@0: */ Chris@0: public function getCellRowContentFormat() Chris@0: { Chris@0: return $this->cellRowContentFormat; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Sets table border format. Chris@0: * Chris@0: * @param string $borderFormat Chris@0: * Chris@0: * @return $this Chris@0: */ Chris@0: public function setBorderFormat($borderFormat) Chris@0: { Chris@0: $this->borderFormat = $borderFormat; Chris@0: Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Gets table border format. Chris@0: * Chris@0: * @return string Chris@0: */ Chris@0: public function getBorderFormat() Chris@0: { Chris@0: return $this->borderFormat; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Sets cell padding type. Chris@0: * Chris@0: * @param int $padType STR_PAD_* Chris@0: * Chris@0: * @return $this Chris@0: */ Chris@0: public function setPadType($padType) Chris@0: { Chris@17: if (!\in_array($padType, [STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH], true)) { Chris@0: throw new InvalidArgumentException('Invalid padding type. Expected one of (STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH).'); Chris@0: } Chris@0: Chris@0: $this->padType = $padType; Chris@0: Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Gets cell padding type. Chris@0: * Chris@0: * @return int Chris@0: */ Chris@0: public function getPadType() Chris@0: { Chris@0: return $this->padType; Chris@0: } Chris@0: }