<?phpnamespace Uniski\ResourceBundle\Entity;use Doctrine\ORM\Mapping as ORM;use Uniski\ResourceBundle\Exception\RoomTypeNotFoundException;/*** @ORM\Entity* @ORM\Table("room_restriction")*/class RoomRestriction{ /** * @var integer * * @ORM\Id * @ORM\Column(name="id", type="integer") * @ORM\GeneratedValue(strategy="IDENTITY") */ protected $id; /** * @var \DateTime * * @ORM\Column(name="date", type="datetime") */ protected $date; /** * @var integer * * @ORM\Column(type="integer") */ protected $minNights; /** * @var string * @ORM\Column(name="room_type", type="string", length=15) */ protected $roomType; /** * @var \Uniski\ResourceBundle\Entity\Hotel * @ORM\ManyToOne(targetEntity="Hotel", inversedBy="restrictions") */ protected $hotel; /** * Set date * * @param \DateTime $date * * @return RoomStock */ public function setDate($date) { $this->date = $date; return $this; } /** * Get date * * @return \DateTime */ public function getDate() { return $this->date; } /** * Set minNights * * @param integer $minNights * * @return RoomStock */ public function setMinNights($minNights) { $this->minNights = $minNights; return $this; } /** * Get minDays * * @return integer */ public function getMinNights() { return $this->minNights; } /** * Set roomType * * @param string * * @return RoomStock */ public function setRoomType($roomType) { if (!is_numeric($roomType)) { $rooms = $this->hotel->getRooms(); foreach ($rooms as $key => $room) { //Using distinct variable name for comparison $roomTypeIte = isset($room["type"]) ? $room["type"]: $key; if ($roomTypeIte === $roomType) { $this->roomType = $roomTypeIte; return $this; } } throw new RoomTypeNotFoundException($roomType); } $this->roomType = $roomType; return $this; } /** * Get roomType * * string */ public function getRoomType() { return $this->roomType; } /** * Get roomName * * string */ public function getRoomName() { $rooms = $this->hotel->getRooms(); if (isset($rooms[$this->roomType])) return $rooms[$this->roomType]['name']; else throw new RoomTypeNotFoundException($this->roomType); } /** * Set hotel * * @param \Uniski\ResourceBundle\Entity\Hotel $hotel * * @return RoomStock */ public function setHotel(\Uniski\ResourceBundle\Entity\Hotel $hotel = null) { $this->hotel = $hotel; return $this; } /** * Get hotel * * @return \Uniski\ResourceBundle\Entity\Hotel */ public function getHotel() { return $this->hotel; } /** * Get id * * @return integer */ public function getId() { return $this->id; }}