[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/vendor/s9e/text-formatter/src/Configurator/Items/AttributeFilters/ -> RangeFilter.php (source)

   1  <?php
   2  
   3  /*
   4  * @package   s9e\TextFormatter
   5  * @copyright Copyright (c) 2010-2019 The s9e Authors
   6  * @license   http://www.opensource.org/licenses/mit-license.php The MIT License
   7  */
   8  namespace s9e\TextFormatter\Configurator\Items\AttributeFilters;
   9  use InvalidArgumentException;
  10  use RuntimeException;
  11  use s9e\TextFormatter\Configurator\Items\AttributeFilter;
  12  class RangeFilter extends AttributeFilter
  13  {
  14  	public function __construct($min = \null, $max = \null)
  15      {
  16          parent::__construct('s9e\\TextFormatter\\Parser\\AttributeFilters\\NumericFilter::filterRange');
  17          $this->resetParameters();
  18          $this->addParameterByName('attrValue');
  19          $this->addParameterByName('min');
  20          $this->addParameterByName('max');
  21          $this->addParameterByName('logger');
  22          $this->setJS('NumericFilter.filterRange');
  23          $this->markAsSafeAsURL();
  24          $this->markAsSafeInCSS();
  25          $this->markAsSafeInJS();
  26          if (isset($min))
  27              $this->setRange($min, $max);
  28      }
  29  	public function asConfig()
  30      {
  31          if (!isset($this->vars['min']))
  32              throw new RuntimeException("Range filter is missing a 'min' value");
  33          if (!isset($this->vars['max']))
  34              throw new RuntimeException("Range filter is missing a 'max' value");
  35          return parent::asConfig();
  36      }
  37  	public function setRange($min, $max)
  38      {
  39          $min = \filter_var($min, \FILTER_VALIDATE_INT);
  40          $max = \filter_var($max, \FILTER_VALIDATE_INT);
  41          if ($min === \false)
  42              throw new InvalidArgumentException('Argument 1 passed to ' . __METHOD__ . ' must be an integer');
  43          if ($max === \false)
  44              throw new InvalidArgumentException('Argument 2 passed to ' . __METHOD__ . ' must be an integer');
  45          if ($min > $max)
  46              throw new InvalidArgumentException('Invalid range: min (' . $min . ') > max (' . $max . ')');
  47          $this->vars['min'] = $min;
  48          $this->vars['max'] = $max;
  49      }
  50  }


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