id === null) { throw new BadRequestException('id is required'); } if ($request->title === null || trim($request->title) === '') { throw new BadRequestException('title is required'); } $element = $this->elementRepository->find($request->id); if ($element === null) { throw new NotFoundException('Element not found'); } $element->setTitle(trim($request->title)); return $this->elementRepository->update($element); } }