src/Uniski/ResourceBundle/Entity/RoomRestriction.php line 12

Open in your IDE?
  1. <?php
  2. namespace Uniski\ResourceBundle\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Uniski\ResourceBundle\Exception\RoomTypeNotFoundException;
  5. /**
  6. * @ORM\Entity
  7. * @ORM\Table("room_restriction")
  8. */
  9. class RoomRestriction
  10. {
  11.   /**
  12.    * @var integer
  13.    *
  14.    * @ORM\Id
  15.    * @ORM\Column(name="id", type="integer")
  16.    * @ORM\GeneratedValue(strategy="IDENTITY")
  17.    */
  18.   protected $id;
  19.   /**
  20.    * @var \DateTime
  21.    *
  22.    * @ORM\Column(name="date", type="datetime")
  23.    */
  24.   protected $date;
  25.   /**
  26.    * @var integer
  27.    *
  28.    * @ORM\Column(type="integer")
  29.    */
  30.   protected $minNights;
  31.   
  32.   /**
  33.    * @var  string
  34.    * @ORM\Column(name="room_type", type="string", length=15)
  35.    */
  36.   protected $roomType;
  37.   /**
  38.    * @var   \Uniski\ResourceBundle\Entity\Hotel
  39.    * @ORM\ManyToOne(targetEntity="Hotel", inversedBy="restrictions")
  40.    */
  41.   protected $hotel;
  42.     /**
  43.      * Set date
  44.      *
  45.      * @param \DateTime $date
  46.      *
  47.      * @return RoomStock
  48.      */
  49.     public function setDate($date)
  50.     {
  51.         $this->date $date;
  52.         return $this;
  53.     }
  54.     /**
  55.      * Get date
  56.      *
  57.      * @return \DateTime
  58.      */
  59.     public function getDate()
  60.     {
  61.         return $this->date;
  62.     }
  63.     /**
  64.      * Set minNights
  65.      *
  66.      * @param integer $minNights
  67.      *
  68.      * @return RoomStock
  69.      */
  70.     public function setMinNights($minNights)
  71.     {
  72.       $this->minNights $minNights;
  73.       return $this;
  74.     }
  75.     /**
  76.      * Get minDays
  77.      *
  78.      * @return integer
  79.      */
  80.     public function getMinNights()
  81.     {
  82.         return $this->minNights;
  83.     }
  84.     /**
  85.      * Set roomType
  86.      *
  87.      * @param string
  88.      *
  89.      * @return RoomStock
  90.      */
  91.     public function setRoomType($roomType)
  92.     {
  93.       if (!is_numeric($roomType)) {
  94.         $rooms $this->hotel->getRooms();
  95.         
  96.         foreach ($rooms as $key => $room) {
  97.           //Using distinct variable name for comparison
  98.           $roomTypeIte = isset($room["type"]) ?
  99.               $room["type"]:
  100.               $key;
  101.           if ($roomTypeIte === $roomType) {
  102.             $this->roomType $roomTypeIte;
  103.             return $this;
  104.           }
  105.         }
  106.         throw new RoomTypeNotFoundException($roomType);
  107.       }
  108.       $this->roomType $roomType;
  109.       return $this;
  110.     }
  111.     /**
  112.      * Get roomType
  113.      *
  114.      * string
  115.      */
  116.     public function getRoomType()
  117.     {
  118.       return $this->roomType;
  119.     }
  120.     /**
  121.      * Get roomName
  122.      *
  123.      * string
  124.      */
  125.     public function getRoomName()
  126.     {
  127.         $rooms $this->hotel->getRooms();
  128.         if (isset($rooms[$this->roomType])) return $rooms[$this->roomType]['name'];
  129.         else throw new RoomTypeNotFoundException($this->roomType);
  130.     }
  131.     /**
  132.      * Set hotel
  133.      *
  134.      * @param \Uniski\ResourceBundle\Entity\Hotel $hotel
  135.      *
  136.      * @return RoomStock
  137.      */
  138.     public function setHotel(\Uniski\ResourceBundle\Entity\Hotel $hotel null)
  139.     {
  140.         $this->hotel $hotel;
  141.         return $this;
  142.     }
  143.     /**
  144.      * Get hotel
  145.      *
  146.      * @return \Uniski\ResourceBundle\Entity\Hotel
  147.      */
  148.     public function getHotel()
  149.     {
  150.         return $this->hotel;
  151.     }
  152.     /**
  153.      * Get id
  154.      *
  155.      * @return integer
  156.      */
  157.     public function getId()
  158.     {
  159.         return $this->id;
  160.     }
  161. }