src/Entity/AbstractFilter.php line 108

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Camper\CamperGroup;
  4. use App\Interface\EntityFilterInterface;
  5. use phpDocumentor\Reflection\Types\Boolean;
  6. class AbstractFilter implements EntityFilterInterface\ArrayAccess\Serializable\JsonSerializable
  7. {
  8.     protected ?string $query=null;
  9.     protected ?\DateTimeInterface $startDate null;
  10.     protected ?\DateTimeInterface $endDate null;
  11.     public function getQuery(): ?string
  12.     {
  13.         return $this->query;
  14.     }
  15.     public function setQuery(?string $query): AbstractFilter
  16.     {
  17.         $this->query $query;
  18.         return $this;
  19.     }
  20.     public function getStartDate(): ?\DateTimeInterface
  21.     {
  22.         return $this->startDate;
  23.     }
  24.     public function setStartDate(?\DateTimeInterface $startDate): AbstractFilter
  25.     {
  26.         $this->startDate $startDate;
  27.         return $this;
  28.     }
  29.     public function getEndDate(): ?\DateTimeInterface
  30.     {
  31.         return $this->endDate;
  32.     }
  33.     public function setEndDate(?\DateTimeInterface $endDate): AbstractFilter
  34.     {
  35.         $this->endDate $endDate;
  36.         return $this;
  37.     }
  38.     /***********************************************/
  39.     public function jsonSerialize()
  40.     {
  41.         return get_object_vars($this);
  42.     }
  43.     function __serialize()
  44.     {
  45.         return get_object_vars($this);
  46.     }
  47.     function __unserialize($array)
  48.     {
  49.         $this->unserialize(json_encode($array));
  50.     }
  51.     public function serialize()
  52.     {
  53.         return serialize(get_object_vars($this));
  54.     }
  55.     public function unserialize($serialized)
  56.     {
  57.         $properties get_object_vars($this);
  58.         $obj json_decode($serialized);
  59.         if (!is_object($obj)) {
  60.             return;
  61.         }
  62.         foreach ($properties as $property => $value) {
  63. //            if(array_key_exists($property,$obj))
  64.             if (property_exists($obj$property)) {
  65.                 switch ($property) {
  66.                     case "startDate":
  67.                     case "endDate":
  68.                         $this->$property = new \DateTime($obj->$property);
  69.                         break;
  70.                     default:
  71.                         $this->$property $obj->$property;
  72.                         break;
  73.                 }
  74.             }
  75.         }
  76.     }
  77.     public function offsetSet($offset$value)
  78.     {
  79.         if (is_null($offset)) {
  80.             $this->container[] = $value;
  81.         } else {
  82.             $this->container[$offset] = $value;
  83.         }
  84.     }
  85.     public function offsetExists($offset)
  86.     {
  87.         return isset($this->container[$offset]);
  88.     }
  89.     public function offsetUnset($offset)
  90.     {
  91.         unset($this->container[$offset]);
  92.     }
  93.     public function offsetGet($offset)
  94.     {
  95.         return isset($this->container[$offset]) ? $this->container[$offset] : null;
  96.     }
  97. }