/** * @param Capacity $capacity * @throws ShakerCapacityOverflowException */ public function pourIn(Capacity $capacity) { if ($capacity->getMilliliters() > $this->capacity->getMilliliters()) { throw new ShakerCapacityOverflowException(); } if ($capacity->getMilliliters() + $this->currentCapacity->getMilliliters() > $this->capacity->getMilliliters()) { throw new ShakerCapacityOverflowException(); } $this->currentCapacity = $this->currentCapacity->add($capacity); }
/** * @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; }
/** * @param Capacity $capacity * @return Liquid */ public function fill(Capacity $capacity) { return new Liquid($this->name, $this->capacity->add($capacity)); }