/** * @param StoryName $storyName * @param ChapterNumber $chapterNumber * @param Message $previousMessage * @return Message */ public function startChapter(StoryName $storyName, ChapterNumber $chapterNumber, Message $previousMessage) { $command = $this->chapterCommandTemplate->createMessageFromPreviousMessage($previousMessage); $command = $command->withAddedMetadata(Metadata::STORY_CHAPTER, $chapterNumber->toString()); return $command->withAddedMetadata(Metadata::STORY_NAME, $storyName->toString()); }
/** * @param ChapterNumber $chapterNumber * @return ChapterStatus */ public static function forChapterNumberCannotBeFound(ChapterNumber $chapterNumber) { return new self(sprintf('Chapter status for chapter number %s cannot be found', $chapterNumber->toString())); }
/** * @param ChapterNumber $chapterNumber * @param MessageFactory $messageFactory * @return Message * @throws Exception\Story */ private function getOriginalStartMessageForChapterNumber(ChapterNumber $chapterNumber, MessageFactory $messageFactory) { if (!isset($this->chapterNumberStartMessageMap[$chapterNumber->toString()])) { throw Exception\Story::hasNoStartMessageLoggedForChapterNumber($chapterNumber); } $messageData = $this->chapterNumberStartMessageMap[$chapterNumber->toString()]; return $messageFactory->createMessageFromArray($messageData['message_name'], $messageData); }