/** * @param Player $player * @return $this * @throws InsufficientBidCoinsException */ private function processBid(Player $player) { if ($player->hasEnoughBidCoins($this->bid_cost)) { if ($player->debitBidCoins($this->bid_cost)) { $this->winner_id = $player->id; $this->value += self::AUCTION_VALUE_INCREMENT; $this->save(); if ($this->status == self::AUCTION_BIDDING || $this->status == self::AUCTION_CHECKING) { $this->resetTimer(); } // record bid in history Bid::record($player, $this); } return $this; } else { throw new InsufficientBidCoinsException(); } }