/** * Penalizes the actor for hitting the rate limit * @return void */ protected function penalize() { // Get the last occuring matching event $last = $this->repository->last($this->event); // Remove all events $this->repository->cleanse($this->event, new Timestamp(time())); // Create a new future penalty event $penalty = new Event($last->getName(), $this->event->getCost(), $last->getTimestamp()->add($this->limit->getPenalty()), $this->event->getActor()); // Add the new event to the repository $this->repository->add($this->event); throw new RateLimitExceededException('Rate limit has been exceeded'); }