[ Index ]

PHP Cross Reference of phpBB-3.3.14-deutsch

title

Body

[close]

/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 <fabien@symfony.com>
   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 <a.aitboudad@gmail.com>
  18   */
  19  class TableCell
  20  {
  21      private $value;
  22      private $options = [
  23          'rowspan' => 1,
  24          'colspan' => 1,
  25      ];
  26  
  27      /**
  28       * @param string $value
  29       */
  30      public function __construct($value = '', array $options = [])
  31      {
  32          if (is_numeric($value) && !\is_string($value)) {
  33              $value = (string) $value;
  34          }
  35  
  36          $this->value = $value;
  37  
  38          // check option names
  39          if ($diff = array_diff(array_keys($options), array_keys($this->options))) {
  40              throw new InvalidArgumentException(sprintf('The TableCell does not support the following options: \'%s\'.', implode('\', \'', $diff)));
  41          }
  42  
  43          $this->options = array_merge($this->options, $options);
  44      }
  45  
  46      /**
  47       * Returns the cell value.
  48       *
  49       * @return string
  50       */
  51      public function __toString()
  52      {
  53          return $this->value;
  54      }
  55  
  56      /**
  57       * Gets number of colspan.
  58       *
  59       * @return int
  60       */
  61      public function getColspan()
  62      {
  63          return (int) $this->options['colspan'];
  64      }
  65  
  66      /**
  67       * Gets number of rowspan.
  68       *
  69       * @return int
  70       */
  71      public function getRowspan()
  72      {
  73          return (int) $this->options['rowspan'];
  74      }
  75  }


Generated: Mon Nov 25 19:05:08 2024 Cross-referenced by PHPXref 0.7.1