src/Entity/Camper/CamperFilter.php line 7

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Camper;
  3. use phpDocumentor\Reflection\Types\Boolean;
  4. class CamperFilter implements \ArrayAccess\Serializable\JsonSerializable
  5. {
  6.     private ?string $query=null;
  7.     private ?\DateTimeInterface $startDate null;
  8.     private ?\DateTimeInterface $endDate null;
  9.     private ?CamperGroup $group null;
  10.     private ?string $gender null;
  11.     public function getQuery(): ?string
  12.     {
  13.         return $this->query;
  14.     }
  15.     public function setQuery(?string $query): CamperFilter
  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): CamperFilter
  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): CamperFilter
  34.     {
  35.         $this->endDate $endDate;
  36.         return $this;
  37.     }
  38.     public function getGroup(): ?CamperGroup
  39.     {
  40.         return $this->group;
  41.     }
  42.     public function setGroup(?CamperGroup $group): CamperFilter
  43.     {
  44.         $this->group $group;
  45.         return $this;
  46.     }
  47.     public function getGender(): ?string
  48.     {
  49.         return $this->gender;
  50.     }
  51.     public function setGender(?string $gender): CamperFilter
  52.     {
  53.         $this->gender $gender;
  54.         return $this;
  55.     }
  56.     /***********************************************/
  57.     public function jsonSerialize()
  58.     {
  59.         return get_object_vars($this);
  60.     }
  61.     function __serialize()
  62.     {
  63.         return get_object_vars($this);
  64.     }
  65.     function __unserialize($array)
  66.     {
  67.         $this->unserialize(json_encode($array));
  68.     }
  69.     public function serialize()
  70.     {
  71.         return serialize(get_object_vars($this));
  72.     }
  73.     public function unserialize($serialized)
  74.     {
  75.         $properties get_object_vars($this);
  76.         $obj json_decode($serialized);
  77.         if (!is_object($obj)) {
  78.             return;
  79.         }
  80.         foreach ($properties as $property => $value) {
  81. //            if(array_key_exists($property,$obj))
  82.             if (property_exists($obj$property)) {
  83.                 switch ($property) {
  84.                     case "startDate":
  85.                     case "endDate":
  86.                         break;
  87.                         $this->$property = new \DateTime($obj->$property);
  88.                     default:
  89.                         $this->$property $obj->$property;
  90.                         break;
  91.                 }
  92.             }
  93.         }
  94.     }
  95.     public function offsetSet($offset$value)
  96.     {
  97.         if (is_null($offset)) {
  98.             $this->container[] = $value;
  99.         } else {
  100.             $this->container[$offset] = $value;
  101.         }
  102.     }
  103.     public function offsetExists($offset)
  104.     {
  105.         return isset($this->container[$offset]);
  106.     }
  107.     public function offsetUnset($offset)
  108.     {
  109.         unset($this->container[$offset]);
  110.     }
  111.     public function offsetGet($offset)
  112.     {
  113.         return isset($this->container[$offset]) ? $this->container[$offset] : null;
  114.     }
  115. }