[ Index ]

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


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1