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: Chris@0: /** Chris@0: * @author Abdellatif Ait boudad Chris@0: */ Chris@0: class TableCell Chris@0: { Chris@0: private $value; Chris@17: private $options = [ Chris@0: 'rowspan' => 1, Chris@0: 'colspan' => 1, Chris@17: ]; Chris@0: Chris@0: /** Chris@0: * @param string $value Chris@0: * @param array $options Chris@0: */ Chris@17: public function __construct($value = '', array $options = []) Chris@0: { Chris@17: if (is_numeric($value) && !\is_string($value)) { Chris@0: $value = (string) $value; Chris@0: } Chris@0: Chris@0: $this->value = $value; Chris@0: Chris@0: // check option names Chris@0: if ($diff = array_diff(array_keys($options), array_keys($this->options))) { Chris@0: throw new InvalidArgumentException(sprintf('The TableCell does not support the following options: \'%s\'.', implode('\', \'', $diff))); Chris@0: } Chris@0: Chris@0: $this->options = array_merge($this->options, $options); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Returns the cell value. Chris@0: * Chris@0: * @return string Chris@0: */ Chris@0: public function __toString() Chris@0: { Chris@0: return $this->value; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Gets number of colspan. Chris@0: * Chris@0: * @return int Chris@0: */ Chris@0: public function getColspan() Chris@0: { Chris@0: return (int) $this->options['colspan']; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Gets number of rowspan. Chris@0: * Chris@0: * @return int Chris@0: */ Chris@0: public function getRowspan() Chris@0: { Chris@0: return (int) $this->options['rowspan']; Chris@0: } Chris@0: }