Esempio n. 1
0
 /**
  * @param Capacity $capacity
  * @throws GlassCapacityOverflowException
  * @throws GlassIsAlreadyOnFireException
  */
 public function pourIn(Capacity $capacity)
 {
     if ($this->isOnFire()) {
         throw new GlassIsAlreadyOnFireException();
     }
     if (!$this->canPourIn($capacity)) {
         throw new GlassCapacityOverflowException();
     }
     if (is_null($this->currentCapacity)) {
         $this->currentCapacity = $capacity;
         return;
     }
     if ($capacity->getMilliliters() + $this->currentCapacity->getMilliliters() > $this->getTotalCapacity()->getMilliliters()) {
         throw new GlassCapacityOverflowException();
     }
     $this->currentCapacity = $this->currentCapacity->add($capacity);
     $this->stirred = false;
     $this->muddled = false;
 }
Esempio n. 2
0
 /**
  * @param Capacity $capacity
  * @return Capacity
  */
 public function subtract(Capacity $capacity)
 {
     return new Capacity($this->milliliters - $capacity->getMilliliters());
 }
Esempio n. 3
0
 /**
  * @return Capacity
  */
 public function getAvailableCapacity()
 {
     return new Capacity($this->capacity->getMilliliters() - $this->currentCapacity->getMilliliters());
 }