Beispiel #1
0
 /**
  * Returns a new ChapterStatus RUNNING with retry count incremented by 1
  * @return ChapterStatus
  * @throws Exception\ChapterStatus
  */
 public function retry()
 {
     if (!$this->isFailed()) {
         throw Exception\ChapterStatus::isNotFailed($this->status, $this->chapterNumber);
     }
     if ($this->retryLimit === $this->retryCount) {
         throw Exception\ChapterStatus::retryLimitReached($this->retryLimit, $this->chapterNumber);
     }
     return new self($this->chapterName, $this->chapterNumber, self::STATUS_RUNNING, $this->retryCount + 1, $this->retryLimit);
 }
Beispiel #2
0
 /**
  * @param ChapterNumber $chapterNumber
  * @param ChapterStatus[] $chapterStates
  * @throws Exception\ChapterStatus
  * @return ChapterStatus
  */
 private function getChapterStatusByChapterNumber(ChapterNumber $chapterNumber, array &$chapterStates)
 {
     foreach ($chapterStates as $chapterStatus) {
         if ($chapterNumber->equals($chapterStatus->chapterNumber())) {
             return $chapterStatus;
         }
     }
     throw Exception\ChapterStatus::forChapterNumberCannotBeFound($chapterNumber);
 }