title === null ? '' : trim($request->title); $body = $request->body === null ? '' : trim($request->body); if ($title === '') { throw new BadRequestException('title is required'); } if ($body === '') { throw new BadRequestException('body is required'); } return $this->postRepo->create(new CreatePostDto( userId: $request->userId, title: $title, body: $body, createdAt: $this->clock->now(), )); } }