textRepo->find($request->textId); if ($text === null) { throw new DomainException("Text with id: {$request->textId} doesnt exist"); } $parentNode = $this->nodeRepo->find($request->parentNodeId); if ($parentNode === null) { throw new DomainException("Node with id: {$request->parentNodeId} doesnt exist"); } $created = []; for ($i = 1; $i <= $request->count; $i++) { $created[] = $this->nodeRepo->create(new CreateNodeDto( text: $text, title: "{$request->titlePrefix} {$i}", parentNode: $parentNode, )); } return $created; } }