/** * Find a Thread by its id * * @param string $id * @return Thread */ private function findThreadById($id) { $thread = $this->threads->threadById(ThreadId::fromString($id)); if ($thread) { return $thread; } throw new ValueNotFoundException("{$id} is not a valid thread id"); }
/** * Create a new Thread * * @param string $user_id * @param string $group_id * @param string $subject * @return Thread */ public function create($user_id, $group_id, $subject) { $user = $this->findUserById($user_id); $group = $this->findGroupById($group_id); $thread = $group->startNewThread($user, $subject); $this->threads->add($thread); /* Dispatch Domain Events */ return $thread; }