{
"event": "PreToolUse",
"tool_name": "Edit",
"tool_input": {
"file_path": "\/var\/www\/dev.campus.systemische-tools.de\/src\/UseCases\/Task\/UpdateTaskStatusUseCase.php",
"old_string": "class UpdateTaskStatusUseCase\n{\n public function __construct(\n private TaskRepositoryInterface $taskRepository,\n private TaskCommentRepository $commentRepository\n ) {\n }\n\n public function execute(int $taskId, string $newStatus, string $updatedBy, string $updatedByType = 'human'): Task",
"new_string": "class UpdateTaskStatusUseCase\n{\n public function __construct(\n private TaskRepositoryInterface $taskRepository,\n private TaskCommentRepository $commentRepository\n ) {\n }\n\n \/**\n * Update task status with workflow validation.\n *\n * @throws \\InvalidArgumentException When task not found or invalid status\n * @throws \\RuntimeException When repository operations fail\n *\/\n public function execute(int $taskId, string $newStatus, string $updatedBy, string $updatedByType = 'human'): Task"
}
}
{
"tool_response": {
"filePath": "\/var\/www\/dev.campus.systemische-tools.de\/src\/UseCases\/Task\/UpdateTaskStatusUseCase.php",
"oldString": "class UpdateTaskStatusUseCase\n{\n public function __construct(\n private TaskRepositoryInterface $taskRepository,\n private TaskCommentRepository $commentRepository\n ) {\n }\n\n public function execute(int $taskId, string $newStatus, string $updatedBy, string $updatedByType = 'human'): Task",
"newString": "class UpdateTaskStatusUseCase\n{\n public function __construct(\n private TaskRepositoryInterface $taskRepository,\n private TaskCommentRepository $commentRepository\n ) {\n }\n\n \/**\n * Update task status with workflow validation.\n *\n * @throws \\InvalidArgumentException When task not found or invalid status\n * @throws \\RuntimeException When repository operations fail\n *\/\n public function execute(int $taskId, string $newStatus, string $updatedBy, string $updatedByType = 'human'): Task",
"originalFile": "<?php\n\ndeclare(strict_types=1);\n\nnamespace UseCases\\Task;\n\n\/\/ @responsibility: Aktualisiert Task-Status mit Workflow-Validierung\n\nuse Domain\\Entity\\Task;\nuse Domain\\Entity\\TaskComment;\nuse Domain\\Repository\\TaskRepositoryInterface;\nuse Infrastructure\\Persistence\\TaskCommentRepository;\n\nclass UpdateTaskStatusUseCase\n{\n public function __construct(\n private TaskRepositoryInterface $taskRepository,\n private TaskCommentRepository $commentRepository\n ) {\n }\n\n public function execute(int $taskId, string $newStatus, string $updatedBy, string $updatedByType = 'human'): Task\n {\n $task = $this->taskRepository->find($taskId);\n if ($task === null) {\n throw new \\InvalidArgumentException(\"Task {$taskId} not found\");\n }\n\n $oldStatus = $task->getStatus();\n\n match ($newStatus) {\n 'in_progress' => $task->start(),\n 'completed' => $task->complete(),\n 'failed' => $task->fail(),\n 'cancelled' => $task->cancel(),\n 'pending' => $task->retry(),\n default => throw new \\InvalidArgumentException(\"Invalid status: {$newStatus}\"),\n };\n\n $this->taskRepository->update($task);\n\n $comment = TaskComment::createStatusChange(\n $taskId,\n $updatedBy,\n $updatedByType,\n $oldStatus->label(),\n $task->getStatus()->label()\n );\n $this->commentRepository->save($comment);\n\n return $task;\n }\n\n public function startTask(int $taskId, string $updatedBy, string $updatedByType = 'human'): Task\n {\n return $this->execute($taskId, 'in_progress', $updatedBy, $updatedByType);\n }\n\n public function completeTask(int $taskId, string $updatedBy, string $updatedByType = 'human'): Task\n {\n return $this->execute($taskId, 'completed', $updatedBy, $updatedByType);\n }\n\n public function failTask(int $taskId, string $updatedBy, string $updatedByType = 'human'): Task\n {\n return $this->execute($taskId, 'failed', $updatedBy, $updatedByType);\n }\n\n public function cancelTask(int $taskId, string $updatedBy, string $updatedByType = 'human'): Task\n {\n return $this->execute($taskId, 'cancelled', $updatedBy, $updatedByType);\n }\n}\n",
"structuredPatch": [
{
"oldStart": 19,
"oldLines": 6,
"newStart": 19,
"newLines": 12,
"lines": [
" ) {",
" }",
" ",
"+ \/**",
"+ * Update task status with workflow validation.",
"+ *",
"+ * @throws \\InvalidArgumentException When task not found or invalid status",
"+ * @throws \\RuntimeException When repository operations fail",
"+ *\/",
" public function execute(int $taskId, string $newStatus, string $updatedBy, string $updatedByType = 'human'): Task",
" {",
" $task = $this->taskRepository->find($taskId);"
]
}
],
"userModified": false,
"replaceAll": false
}
}