[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/vendor/symfony/console/Helper/ -> TableCell.php (source)

   1  <?php
   2  
   3  /*
   4   * This file is part of the Symfony package.
   5   *
   6   * (c) Fabien Potencier <[email protected]>
   7   *
   8   * For the full copyright and license information, please view the LICENSE
   9   * file that was distributed with this source code.
  10   */
  11  
  12  namespace Symfony\Component\Console\Helper;
  13  
  14  use Symfony\Component\Console\Exception\InvalidArgumentException;
  15  
  16  /**
  17   * @author Abdellatif Ait boudad <[email protected]>
  18   */
  19  class TableCell
  20  {
  21      private $value;
  22      private $options = [
  23          'rowspan' => 1,
  24          'colspan' => 1,
  25          'style' => null,
  26      ];
  27  
  28      public function __construct(string $value = '', array $options = [])
  29      {
  30          $this->value = $value;
  31  
  32          // check option names
  33          if ($diff = array_diff(array_keys($options), array_keys($this->options))) {
  34              throw new InvalidArgumentException(sprintf('The TableCell does not support the following options: \'%s\'.', implode('\', \'', $diff)));
  35          }
  36  
  37          if (isset($options['style']) && !$options['style'] instanceof TableCellStyle) {
  38              throw new InvalidArgumentException('The style option must be an instance of "TableCellStyle".');
  39          }
  40  
  41          $this->options = array_merge($this->options, $options);
  42      }
  43  
  44      /**
  45       * Returns the cell value.
  46       *
  47       * @return string
  48       */
  49      public function __toString()
  50      {
  51          return $this->value;
  52      }
  53  
  54      /**
  55       * Gets number of colspan.
  56       *
  57       * @return int
  58       */
  59      public function getColspan()
  60      {
  61          return (int) $this->options['colspan'];
  62      }
  63  
  64      /**
  65       * Gets number of rowspan.
  66       *
  67       * @return int
  68       */
  69      public function getRowspan()
  70      {
  71          return (int) $this->options['rowspan'];
  72      }
  73  
  74      public function getStyle(): ?TableCellStyle
  75      {
  76          return $this->options['style'];
  77      }
  78  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer