vendor/shopware/core/Framework/DataAbstractionLayer/Search/Filter/RangeFilter.php line 11

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Framework\DataAbstractionLayer\Search\Filter;
  3. use Shopware\Core\Framework\Log\Package;
  4. /**
  5.  * @final tag:v6.5.0
  6.  */
  7. #[Package('core')]
  8. class RangeFilter extends SingleFieldFilter
  9. {
  10.     public const LTE 'lte';
  11.     public const LT 'lt';
  12.     public const GTE 'gte';
  13.     public const GT 'gt';
  14.     /**
  15.      * @var string
  16.      */
  17.     protected $field;
  18.     /**
  19.      * @var array
  20.      */
  21.     protected $parameters = [];
  22.     /**
  23.      * @example
  24.      *
  25.      * new RangeFilter('price', [
  26.      *      RangeFilter::GTE => 5.99,
  27.      *      RangeFilter::LTE => 21.99
  28.      * ])
  29.      *
  30.      * new RangeFilter('price', [
  31.      *      RangeFilter::GT => 5.99
  32.      * ])
  33.      */
  34.     public function __construct(string $field, array $parameters = [])
  35.     {
  36.         $this->field $field;
  37.         $this->parameters $parameters;
  38.     }
  39.     public function hasParameter(string $key)
  40.     {
  41.         return \array_key_exists($key$this->parameters);
  42.     }
  43.     public function getParameter(string $key)
  44.     {
  45.         if (!$this->hasParameter($key)) {
  46.             return null;
  47.         }
  48.         return $this->parameters[$key];
  49.     }
  50.     public function getField(): string
  51.     {
  52.         return $this->field;
  53.     }
  54.     public function getParameters(): array
  55.     {
  56.         return $this->parameters;
  57.     }
  58.     public function getFields(): array
  59.     {
  60.         return [$this->field];
  61.     }
  62. }