src/Entity/Residence/BookingsFilter.php line 126

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Residence;
  3. use App\Repository\Residence\BookingsFilterRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. class BookingsFilter implements \ArrayAccess\Serializable\JsonSerializable
  6. {
  7.     private ?Building $building null;
  8.     private \DateTime $startDate;
  9.     private \DateTime $endDate;
  10.     private bool $flagOnlyCheckedIn=false;
  11.     private bool $flagOnlyNotCheckedIn=false;
  12.     private bool $flagOnlyCheckedOut=false;
  13.     private bool $flagOnlyNotCheckedOut=false;
  14.     public function __construct()
  15.     {
  16.         $this->startDate=new \DateTime();
  17.         $this->startDate->add(new \DateInterval('-2W'));
  18.         $this->endDate=new \DateTime();
  19.         $this->endDate->add(new \DateInterval('+2W'));
  20.     }
  21.     /**
  22.      * @return Building|null
  23.      */
  24.     public function getBuilding(): ?Building
  25.     {
  26.         return $this->building;
  27.     }
  28.     /**
  29.      * @param Building|null $building
  30.      *
  31.      * @return BookingsFilter
  32.      */
  33.     public function setBuilding(?Building $building): BookingsFilter
  34.     {
  35.         $this->building $building;
  36.         return $this;
  37.     }
  38.     /**
  39.      * @return \DateTime
  40.      */
  41.     public function getStartDate(): \DateTime
  42.     {
  43.         return $this->startDate;
  44.     }
  45.     /**
  46.      * @param \DateTime $startDate
  47.      *
  48.      * @return BookingsFilter
  49.      */
  50.     public function setStartDate(\DateTime $startDate): BookingsFilter
  51.     {
  52.         $this->startDate $startDate;
  53.         return $this;
  54.     }
  55.     /**
  56.      * @return \DateTime
  57.      */
  58.     public function getEndDate(): \DateTime
  59.     {
  60.         return $this->endDate;
  61.     }
  62.     /**
  63.      * @param \DateTime $endDate
  64.      *
  65.      * @return BookingsFilter
  66.      */
  67.     public function setEndDate(\DateTime $endDate): BookingsFilter
  68.     {
  69.         $this->endDate $endDate;
  70.         return $this;
  71.     }
  72.     /**
  73.      * @return bool
  74.      */
  75.     public function isFlagOnlyCheckedIn(): bool
  76.     {
  77.         return $this->flagOnlyCheckedIn;
  78.     }
  79.     /**
  80.      * @return bool
  81.      */
  82.     public function isFlagOnlyNotCheckedIn(): bool
  83.     {
  84.         return $this->flagOnlyNotCheckedIn;
  85.     }
  86.     /**
  87.      * @return bool
  88.      */
  89.     public function isFlagOnlyCheckedOut(): bool
  90.     {
  91.         return $this->flagOnlyCheckedOut;
  92.     }
  93.     /**
  94.      * @return bool
  95.      */
  96.     public function isFlagOnlyNotCheckedOut(): bool
  97.     {
  98.         return $this->flagOnlyNotCheckedOut;
  99.     }
  100.     public function offsetSet($offset$value)
  101.     {
  102.         if (is_null($offset)) {
  103.             $this->container[] = $value;
  104.         } else {
  105.             $this->container[$offset] = $value;
  106.         }
  107.     }
  108.     public function offsetExists($offset)
  109.     {
  110.         return isset($this->container[$offset]);
  111.     }
  112.     public function offsetUnset($offset)
  113.     {
  114.         unset($this->container[$offset]);
  115.     }
  116.     public function offsetGet($offset)
  117.     {
  118.         return isset($this->container[$offset]) ? $this->container[$offset] : null;
  119.     }
  120.     public function jsonSerialize()
  121.     {
  122.         return get_object_vars($this);
  123.     }
  124.     function __serialize() {
  125.         return get_object_vars($this);
  126.     }
  127.     function __unserialize($array) {
  128.         $this->unserialize(json_encode($array));
  129.     }
  130.     public function serialize()
  131.     {
  132.         return serialize(get_object_vars($this));
  133.     }
  134.     public function unserialize($serialized)
  135.     {
  136. //        dd($serialized);
  137.         $properties get_object_vars($this);
  138.         $obj json_decode($serialized);
  139.         if (!is_object($obj)) {
  140.             return;
  141.         }
  142.         foreach ($properties as $property => $value) {
  143. //            if(array_key_exists($property,$obj))
  144.             if (property_exists($obj$property)) {
  145.                 switch($property) {
  146.                     case "startDate":
  147.                     case "endDate":
  148.                         break;
  149.                         $this->$property = new \DateTime($obj->$property);
  150.                     default:
  151.                         $this->$property $obj->$property;
  152.                         break;
  153.                 }
  154.             }
  155.         }
  156.     }
  157. }