<?php
namespace App\Entity\Residence;
use App\Repository\Residence\BookingsFilterRepository;
use Doctrine\ORM\Mapping as ORM;
class BookingsFilter implements \ArrayAccess, \Serializable, \JsonSerializable
{
private ?Building $building = null;
private \DateTime $startDate;
private \DateTime $endDate;
private bool $flagOnlyCheckedIn=false;
private bool $flagOnlyNotCheckedIn=false;
private bool $flagOnlyCheckedOut=false;
private bool $flagOnlyNotCheckedOut=false;
public function __construct()
{
$this->startDate=new \DateTime();
$this->startDate->add(new \DateInterval('-2W'));
$this->endDate=new \DateTime();
$this->endDate->add(new \DateInterval('+2W'));
}
/**
* @return Building|null
*/
public function getBuilding(): ?Building
{
return $this->building;
}
/**
* @param Building|null $building
*
* @return BookingsFilter
*/
public function setBuilding(?Building $building): BookingsFilter
{
$this->building = $building;
return $this;
}
/**
* @return \DateTime
*/
public function getStartDate(): \DateTime
{
return $this->startDate;
}
/**
* @param \DateTime $startDate
*
* @return BookingsFilter
*/
public function setStartDate(\DateTime $startDate): BookingsFilter
{
$this->startDate = $startDate;
return $this;
}
/**
* @return \DateTime
*/
public function getEndDate(): \DateTime
{
return $this->endDate;
}
/**
* @param \DateTime $endDate
*
* @return BookingsFilter
*/
public function setEndDate(\DateTime $endDate): BookingsFilter
{
$this->endDate = $endDate;
return $this;
}
/**
* @return bool
*/
public function isFlagOnlyCheckedIn(): bool
{
return $this->flagOnlyCheckedIn;
}
/**
* @return bool
*/
public function isFlagOnlyNotCheckedIn(): bool
{
return $this->flagOnlyNotCheckedIn;
}
/**
* @return bool
*/
public function isFlagOnlyCheckedOut(): bool
{
return $this->flagOnlyCheckedOut;
}
/**
* @return bool
*/
public function isFlagOnlyNotCheckedOut(): bool
{
return $this->flagOnlyNotCheckedOut;
}
public function offsetSet($offset, $value)
{
if (is_null($offset)) {
$this->container[] = $value;
} else {
$this->container[$offset] = $value;
}
}
public function offsetExists($offset)
{
return isset($this->container[$offset]);
}
public function offsetUnset($offset)
{
unset($this->container[$offset]);
}
public function offsetGet($offset)
{
return isset($this->container[$offset]) ? $this->container[$offset] : null;
}
public function jsonSerialize()
{
return get_object_vars($this);
}
function __serialize() {
return get_object_vars($this);
}
function __unserialize($array) {
$this->unserialize(json_encode($array));
}
public function serialize()
{
return serialize(get_object_vars($this));
}
public function unserialize($serialized)
{
// dd($serialized);
$properties = get_object_vars($this);
$obj = json_decode($serialized);
if (!is_object($obj)) {
return;
}
foreach ($properties as $property => $value) {
// if(array_key_exists($property,$obj))
if (property_exists($obj, $property)) {
switch($property) {
case "startDate":
case "endDate":
break;
$this->$property = new \DateTime($obj->$property);
default:
$this->$property = $obj->$property;
break;
}
}
}
}
}