vendor/bitbag/elasticsearch-plugin/src/Model/SearchFacets.php line 17

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file has been created by developers from BitBag.
  4.  * Feel free to contact us once you face any issues or want to start
  5.  * another great project.
  6.  * You can find more information about us on https://bitbag.io and write us
  7.  * an email on hello@bitbag.io.
  8.  */
  9. declare(strict_types=1);
  10. namespace BitBag\SyliusElasticsearchPlugin\Model;
  11. use Iterator;
  12. final class SearchFacets implements Iterator
  13. {
  14.     private array $selectedBuckets = [];
  15.     public function __get(string $facetId)
  16.     {
  17.         if (!array_key_exists($facetId$this->selectedBuckets)) {
  18.             return [];
  19.         }
  20.         return $this->selectedBuckets[$facetId];
  21.     }
  22.     public function __set(string $facetId$selectedBuckets)
  23.     {
  24.         $this->selectedBuckets[$facetId] = $selectedBuckets;
  25.     }
  26.     public function __isset(string $facetId)
  27.     {
  28.         return isset($this->selectedBuckets[$facetId]);
  29.     }
  30.     /**
  31.      * @inheritdoc
  32.      */
  33.     public function current(): mixed
  34.     {
  35.         return current($this->selectedBuckets);
  36.     }
  37.     /**
  38.      * @inheritdoc
  39.      */
  40.     public function next(): void
  41.     {
  42.         next($this->selectedBuckets);
  43.     }
  44.     /**
  45.      * @inheritdoc
  46.      */
  47.     public function key(): mixed
  48.     {
  49.         return key($this->selectedBuckets);
  50.     }
  51.     /**
  52.      * @inheritdoc
  53.      */
  54.     public function valid(): bool
  55.     {
  56.         $key key($this->selectedBuckets);
  57.         return null !== $key && false !== $key;
  58.     }
  59.     /**
  60.      * @inheritdoc
  61.      */
  62.     public function rewind(): void
  63.     {
  64.         reset($this->selectedBuckets);
  65.     }
  66. }