{
"event": "PreToolUse",
"tool_name": "Edit",
"tool_input": {
"file_path": "\/var\/www\/dev.campus.systemische-tools.de\/src\/UseCases\/Task\/CreateTaskUseCase.php",
"old_string": "<?php\n\nnamespace UseCases\\Task;\n\nuse Domain\\Entity\\Task;\nuse Domain\\Entity\\TaskComment;\nuse Infrastructure\\Persistence\\TaskCommentRepository;\nuse Infrastructure\\Persistence\\TaskRepository;\n\nclass CreateTaskUseCase",
"new_string": "<?php\n\ndeclare(strict_types=1);\n\nnamespace UseCases\\Task;\n\n\/\/ @responsibility: Erstellt neue Tasks mit optionalen Kommentaren und Parent-Verknüpfung\n\nuse Domain\\Entity\\Task;\nuse Domain\\Entity\\TaskComment;\nuse Infrastructure\\Persistence\\TaskCommentRepository;\nuse Infrastructure\\Persistence\\TaskRepository;\n\nclass CreateTaskUseCase"
}
}
{
"tool_response": {
"filePath": "\/var\/www\/dev.campus.systemische-tools.de\/src\/UseCases\/Task\/CreateTaskUseCase.php",
"oldString": "<?php\n\nnamespace UseCases\\Task;\n\nuse Domain\\Entity\\Task;\nuse Domain\\Entity\\TaskComment;\nuse Infrastructure\\Persistence\\TaskCommentRepository;\nuse Infrastructure\\Persistence\\TaskRepository;\n\nclass CreateTaskUseCase",
"newString": "<?php\n\ndeclare(strict_types=1);\n\nnamespace UseCases\\Task;\n\n\/\/ @responsibility: Erstellt neue Tasks mit optionalen Kommentaren und Parent-Verknüpfung\n\nuse Domain\\Entity\\Task;\nuse Domain\\Entity\\TaskComment;\nuse Infrastructure\\Persistence\\TaskCommentRepository;\nuse Infrastructure\\Persistence\\TaskRepository;\n\nclass CreateTaskUseCase",
"originalFile": "<?php\n\nnamespace UseCases\\Task;\n\nuse Domain\\Entity\\Task;\nuse Domain\\Entity\\TaskComment;\nuse Infrastructure\\Persistence\\TaskCommentRepository;\nuse Infrastructure\\Persistence\\TaskRepository;\n\nclass CreateTaskUseCase\n{\n private TaskRepository $taskRepository;\n private TaskCommentRepository $commentRepository;\n\n public function __construct(\n ?TaskRepository $taskRepository = null,\n ?TaskCommentRepository $commentRepository = null\n ) {\n $this->taskRepository = $taskRepository ?? new TaskRepository();\n $this->commentRepository = $commentRepository ?? new TaskCommentRepository();\n }\n\n public function execute(array $data): Task\n {\n $this->validate($data);\n\n $task = new Task();\n $task->setTitle($data['title']);\n $task->setCreatedBy($data['created_by'] ?? 'system');\n $task->setCreatedByType($data['created_by_type'] ?? 'human');\n\n if (isset($data['description'])) {\n $task->setDescription($data['description']);\n }\n\n if (isset($data['type'])) {\n $task->setType($data['type']);\n }\n\n if (isset($data['parent_task_id'])) {\n $task->setParentTaskId((int) $data['parent_task_id']);\n }\n\n if (isset($data['due_date'])) {\n $task->setDueDate(new \\DateTimeImmutable($data['due_date']));\n }\n\n if (isset($data['metadata'])) {\n $task->setMetadata($data['metadata']);\n }\n\n $id = $this->taskRepository->save($task);\n $task->setId($id);\n\n $comment = new TaskComment();\n $comment->setTaskId($id);\n $comment->setAuthor($task->getCreatedBy());\n $comment->setAuthorType($task->getCreatedByType());\n $comment->setCommentType('note');\n $comment->setContent('Task erstellt');\n $this->commentRepository->save($comment);\n\n return $task;\n }\n\n private function validate(array $data): void\n {\n if (!isset($data['title']) || $data['title'] === '') {\n throw new \\InvalidArgumentException('Title is required');\n }\n\n if (strlen($data['title']) > 255) {\n throw new \\InvalidArgumentException('Title must be 255 characters or less');\n }\n\n if (isset($data['type']) && !in_array($data['type'], ['human_task', 'ai_task', 'mixed'])) {\n throw new \\InvalidArgumentException('Invalid task type');\n }\n }\n}\n",
"structuredPatch": [
{
"oldStart": 1,
"oldLines": 7,
"newStart": 1,
"newLines": 11,
"lines": [
" <?php",
" ",
"+declare(strict_types=1);",
"+",
" namespace UseCases\\Task;",
" ",
"+\/\/ @responsibility: Erstellt neue Tasks mit optionalen Kommentaren und Parent-Verknüpfung",
"+",
" use Domain\\Entity\\Task;",
" use Domain\\Entity\\TaskComment;",
" use Infrastructure\\Persistence\\TaskCommentRepository;"
]
}
],
"userModified": false,
"replaceAll": false
}
}