src/Entity/AbstractFilter.php line 112

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