src/Entity/FoodFilterCounter.php line 9

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Slivki\Entity;
  4. use Slivki\Services\Offer\CustomProductOfferSorter;
  5. class FoodFilterCounter
  6. {
  7.     private $ID;
  8.     private $entityID;
  9.     private $open;
  10.     private $recommended;
  11.     private $popular;
  12.     private $speed;
  13.     private $ascPrice;
  14.     private $descPrice;
  15.     private $priceByKg;
  16.     private int $popularDay;
  17.     private int $priceByKgDesc;
  18.     public function __construct(int $entityID)
  19.     {
  20.         $this->entityID $entityID;
  21.         $this->popularDay 0;
  22.         $this->priceByKgDesc 0;
  23.     }
  24.     public function getID(): int
  25.     {
  26.         return $this->ID;
  27.     }
  28.     public function getEntityID(): int
  29.     {
  30.         return $this->entityID;
  31.     }
  32.     public function getOpen(): ?int
  33.     {
  34.         return $this->open;
  35.     }
  36.     public function getRecommended(): ?int
  37.     {
  38.         return $this->recommended;
  39.     }
  40.     public function getPopular(): ?int
  41.     {
  42.         return $this->popular;
  43.     }
  44.     public function getSpeed(): ?int
  45.     {
  46.         return $this->speed;
  47.     }
  48.     public function getAscPrice(): ?int
  49.     {
  50.         return $this->ascPrice;
  51.     }
  52.     public function getDescPrice(): ?int
  53.     {
  54.         return $this->descPrice;
  55.     }
  56.     public function getPriceByKg(): ?int
  57.     {
  58.         return $this->priceByKg;
  59.     }
  60.     public function getPopularDay(): int
  61.     {
  62.         return $this->popularDay;
  63.     }
  64.     public function getPriceByKgDesc(): int
  65.     {
  66.         return $this->priceByKgDesc;
  67.     }
  68.     public function increaseDeliverySortFilterStat(string $sort): void
  69.     {
  70.         switch ($sort) {
  71.             case CustomProductOfferSorter::DEFAULT_CUSTOM_PRODUCT_SORT:
  72.                 $this->increaseRecommended();
  73.                 break;
  74.             case CustomProductOfferSorter::POPULARITY_CUSTOM_PRODUCT_SORT:
  75.                 $this->increasePopular();
  76.                 break;
  77.             case CustomProductOfferSorter::FAST_CUSTOM_PRODUCT_SORT:
  78.                 $this->increaseSpeed();
  79.                 break;
  80.             case CustomProductOfferSorter::PRICE_CUSTOM_PRODUCT_SORT:
  81.                 $this->increaseAscPrice();
  82.                 break;
  83.             case CustomProductOfferSorter::EXPENSIVE_CUSTOM_PRODUCT_SORT:
  84.                 $this->increaseDescPrice();
  85.                 break;
  86.             case CustomProductOfferSorter::PRICE_CUSTOM_PRODUCT_PRICE_PER_KILOGRAM:
  87.                 $this->increasePriceByKg();
  88.                 break;
  89.             case CustomProductOfferSorter::OPEN_FILTER:
  90.                 $this->increaseOpen();
  91.                 break;
  92.             case CustomProductOfferSorter::POPULARITY_DAY_CUSTOM_PRODUCT_SORT:
  93.                 $this->increasePopularDay();
  94.                 break;
  95.             case CustomProductOfferSorter::PRICE_CUSTOM_PRODUCT_PRICE_PER_KILOGRAM_DESC:
  96.                 $this->increasePriceByKgDesc();
  97.                 break;
  98.         }
  99.     }
  100.     private function increaseOpen(): void
  101.     {
  102.         ++$this->open;
  103.     }
  104.     private function increasePriceByKg(): void
  105.     {
  106.         ++$this->priceByKg;
  107.     }
  108.     private function increaseDescPrice(): void
  109.     {
  110.         ++$this->descPrice;
  111.     }
  112.     private function increaseAscPrice(): void
  113.     {
  114.         ++$this->ascPrice;
  115.     }
  116.     private function increaseSpeed(): void
  117.     {
  118.         ++$this->speed;
  119.     }
  120.     private function increasePopular(): void
  121.     {
  122.         ++$this->popular;
  123.     }
  124.     private function increaseRecommended() : void
  125.     {
  126.         ++$this->recommended;
  127.     }
  128.     private function increasePopularDay(): void
  129.     {
  130.         ++$this->popularDay;
  131.     }
  132.     private function increasePriceByKgDesc(): void
  133.     {
  134.         ++$this->priceByKgDesc;
  135.     }
  136. }