src/Entity/Residence/RoomFilter.php line 287

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Residence;
  3. use App\Entity\Camper\CamperProfile;
  4. use App\Entity\School\Student\StudentProfile;
  5. use Symfony\Component\Validator\Constraints as Assert;
  6. class RoomFilter implements \ArrayAccess\Serializable\JsonSerializable
  7. {
  8.     private ?Building $building null;
  9.     private ?Floor $floor null;
  10.     private ?Wing $wing null;
  11.     private ?string $extra null;
  12.     private ?string $modal null;
  13.     private \DateTimeInterface $startdate;
  14.     private \DateTimeInterface $enddate;
  15.     private ?Beds $bedspace=null;
  16.     private ?OccupantInterface $occupant=null;
  17.     private ?StudentProfile $student=null;
  18.     private ?CamperProfile $camper=null;
  19.     private ?bool $forCamper=null;
  20.         private ?string $query=null;
  21.     public function __construct()
  22.     {
  23.         $this->startdate=new \DateTime();
  24.         $this->enddate=new \DateTime();
  25.     }
  26.     public function getBuilding(): ?Building
  27.     {
  28.         return $this->building;
  29.     }
  30.     /**
  31.      * @param Building|null $building
  32.      *
  33.      * @return RoomFilter
  34.      */
  35.     public function setBuilding(?Building $building): RoomFilter
  36.     {
  37.         $this->building $building;
  38.         return $this;
  39.     }
  40.     public function getFloor(): ?Floor
  41.     {
  42.         return $this->floor;
  43.     }
  44.     /**
  45.      * @param Floor|null $floor
  46.      *
  47.      * @return RoomFilter
  48.      */
  49.     public function setFloor(?Floor $floor): RoomFilter
  50.     {
  51.         $this->floor $floor;
  52.         return $this;
  53.     }
  54.     public function getWing(): ?Wing
  55.     {
  56.         return $this->wing;
  57.     }
  58.     /**
  59.      * @param Wing|null $wing
  60.      *
  61.      * @return RoomFilter
  62.      */
  63.     public function setWing(?Wing $wing): RoomFilter
  64.     {
  65.         $this->wing $wing;
  66.         return $this;
  67.     }
  68.     public function getExtra(): ?string
  69.     {
  70.         return $this->extra;
  71.     }
  72.     /**
  73.      * @param string|null $extra
  74.      *
  75.      * @return RoomFilter
  76.      */
  77.     public function setExtra(?string $extra): RoomFilter
  78.     {
  79.         $this->extra $extra;
  80.         return $this;
  81.     }
  82.     /**
  83.      * @return string|null
  84.      */
  85.     public function getModal(): ?string
  86.     {
  87.         return $this->modal;
  88.     }
  89.     /**
  90.      * @param string|null $modal
  91.      *
  92.      * @return RoomFilter
  93.      */
  94.     public function setModal(?string $modal): RoomFilter
  95.     {
  96.         $this->modal $modal;
  97.         return $this;
  98.     }
  99.     /**
  100.      * @param string|null $modal
  101.      */
  102.     /**
  103.      * @return \DateTime
  104.      */
  105.     public function getStartdate(): \DateTime
  106.     {
  107.         return $this->startdate;
  108.     }
  109.     /**
  110.      * @param \DateTime $startdate
  111.      *
  112.      * @return RoomFilter
  113.      */
  114.     public function setStartdate(\DateTime $startdate): RoomFilter
  115.     {
  116.         $this->startdate $startdate;
  117.         return $this;
  118.     }
  119.     /**
  120.      * @param \DateTime $startdate
  121.      */
  122.     /**
  123.      * @return \DateTime
  124.      */
  125.     public function getEnddate(): \DateTime
  126.     {
  127.         return $this->enddate;
  128.     }
  129.     /**
  130.      * @param \DateTime $enddate
  131.      *
  132.      * @return RoomFilter
  133.      */
  134.     public function setEnddate(\DateTime $enddate): RoomFilter
  135.     {
  136.         $this->enddate $enddate;
  137.         return $this;
  138.     }
  139.     /**
  140.      * @param \DateTime $enddate
  141.      */
  142.     /**
  143.      * @return Beds|null
  144.      */
  145.     public function getBedspace(): ?Beds
  146.     {
  147.         return $this->bedspace;
  148.     }
  149.     /**
  150.      * @param Beds|null $bedspace
  151.      * @return RoomFilter
  152.      */
  153.     public function setBedspace(?Beds $bedspace): RoomFilter
  154.     {
  155.         $this->bedspace $bedspace;
  156.         return $this;
  157.     }
  158.     /**
  159.      * @return Occupancy|null
  160.      */
  161.     public function getOccupant(): ?OccupantInterface
  162.     {
  163.         return $this->occupant;
  164.     }
  165.     /**
  166.      * @param OccupantInterface|null $occupant
  167.      *
  168.      * @return RoomFilter
  169.      */
  170.     public function setOccupant(?OccupantInterface $occupant): RoomFilter
  171.     {
  172.         $this->occupant $occupant;
  173.         if($occupant instanceof StudentProfile)
  174.             $this->student=$occupant;
  175.         if($occupant instanceof CamperProfile)
  176.             $this->camper=$occupant;
  177.         return $this;
  178.     }
  179.     public function getForCamper(): ?bool
  180.     {
  181.         return $this->forCamper;
  182.     }
  183.     public function setForCamper(?bool $forCamper): void
  184.     {
  185.         $this->forCamper $forCamper;
  186.     }
  187.     public function getStudent(): ?StudentProfile
  188.     {
  189.         return $this->student;
  190.     }
  191.     public function setStudent(?StudentProfile $student): RoomFilter
  192.     {
  193.         $this->student $student;
  194.         return $this;
  195.     }
  196.     public function getCamper(): ?CamperProfile
  197.     {
  198.         return $this->camper;
  199.     }
  200.     public function setCamper(?CamperProfile $camper): RoomFilter
  201.     {
  202.         $this->camper $camper;
  203.         return $this;
  204.     }
  205.     /**
  206.      * @return string|null
  207.      */
  208.     public function getQuery(): ?string
  209.     {
  210.         return $this->query;
  211.     }
  212.     /**
  213.      * @param string|null $query
  214.      * @return RoomFilter
  215.      */
  216.     public function setQuery(?string $query): RoomFilter
  217.     {
  218.         $this->query $query;
  219.         return $this;
  220.     }
  221.     public function offsetSet($offset$value)
  222.     {
  223.         if (is_null($offset)) {
  224.             $this->container[] = $value;
  225.         } else {
  226.             $this->container[$offset] = $value;
  227.         }
  228.     }
  229.     public function offsetExists($offset)
  230.     {
  231.         return isset($this->container[$offset]);
  232.     }
  233.     public function offsetUnset($offset)
  234.     {
  235.         unset($this->container[$offset]);
  236.     }
  237.     public function offsetGet($offset)
  238.     {
  239.         return isset($this->container[$offset]) ? $this->container[$offset] : null;
  240.     }
  241.     public function jsonSerialize()
  242.     {
  243.         return get_object_vars($this);
  244.     }
  245.     public function serialize()
  246.     {
  247.         return serialize(get_object_vars($this));
  248.     }
  249.     public function unserialize($serialized)
  250.     {
  251. //        dd($serialized);
  252.         $properties get_object_vars($this);
  253.         $obj json_decode($serialized);
  254.         if (!is_object($obj)) {
  255.             return;
  256.         }
  257.         foreach ($properties as $property => $value) {
  258. //            if(array_key_exists($property,$obj))
  259.             if (property_exists($obj$property)) {
  260.                 switch($property) {
  261.                     case "startdate":
  262.                     case "enddate":
  263.                         break;
  264.                         $this->$property = new \DateTime($obj->$property);
  265.                     default:
  266.                         $this->$property $obj->$property;
  267.                         break;
  268.                 }
  269.             }
  270.         }
  271.     }
  272. }