{
"event": "PreToolUse",
"tool_name": "Edit",
"tool_input": {
"file_path": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Domain\/Entity\/Task.php",
"old_string": " public function toArray(): array\n {\n return [\n 'id' => $this->id,\n 'uuid' => $this->uuid,\n 'title' => $this->title,\n 'description' => $this->description,\n 'type' => $this->type,\n 'status' => $this->status->value,\n 'created_by' => $this->createdBy,\n 'created_by_type' => $this->createdByType,\n 'parent_task_id' => $this->parentTaskId,\n 'due_date' => $this->dueDate?->format('Y-m-d H:i:s'),\n 'created_at' => $this->createdAt->format('Y-m-d H:i:s.u'),\n 'updated_at' => $this->updatedAt->format('Y-m-d H:i:s.u'),\n 'completed_at' => $this->completedAt?->format('Y-m-d H:i:s.u'),\n 'metadata' => $this->metadata,\n ];\n }\n\n public static function fromArray(array $data): self\n {\n $task = new self();\n\n if (isset($data['id'])) {\n $task->setId((int) $data['id']);\n }\n if (isset($data['uuid'])) {\n $task->setUuid($data['uuid']);\n }\n if (isset($data['title'])) {\n $task->setTitle($data['title']);\n }\n if (isset($data['description'])) {\n $task->setDescription($data['description']);\n }\n if (isset($data['type'])) {\n $task->setType($data['type']);\n }\n if (isset($data['status'])) {\n $task->status = TaskStatus::from($data['status']);\n }\n if (isset($data['created_by'])) {\n $task->setCreatedBy($data['created_by']);\n }\n if (isset($data['created_by_type'])) {\n $task->setCreatedByType($data['created_by_type']);\n }\n if (isset($data['parent_task_id'])) {\n $task->setParentTaskId((int) $data['parent_task_id']);\n }\n if (isset($data['due_date'])) {\n $task->setDueDate(new \\DateTimeImmutable($data['due_date']));\n }\n if (isset($data['created_at'])) {\n $task->setCreatedAt(new \\DateTimeImmutable($data['created_at']));\n }\n if (isset($data['updated_at'])) {\n $task->setUpdatedAt(new \\DateTimeImmutable($data['updated_at']));\n }\n if (isset($data['completed_at'])) {\n $task->setCompletedAt(new \\DateTimeImmutable($data['completed_at']));\n }\n if (isset($data['metadata'])) {\n $metadata = is_string($data['metadata']) ? json_decode($data['metadata'], true) : $data['metadata'];\n $task->setMetadata($metadata ?? []);\n }\n\n return $task;\n }\n}",
"new_string": " public function toArray(): array\n {\n return [\n 'id' => $this->id,\n 'uuid' => $this->uuid,\n 'title' => $this->title,\n 'description' => $this->description,\n 'type' => $this->type->value,\n 'status' => $this->status->value,\n 'created_by' => $this->createdBy,\n 'created_by_type' => $this->createdByType,\n 'parent_task_id' => $this->parentTaskId,\n 'due_date' => $this->dueDate?->format('Y-m-d H:i:s'),\n 'created_at' => $this->createdAt->format('Y-m-d H:i:s.u'),\n 'updated_at' => $this->updatedAt->format('Y-m-d H:i:s.u'),\n 'completed_at' => $this->completedAt?->format('Y-m-d H:i:s.u'),\n 'metadata' => $this->metadata,\n ];\n }\n\n public static function fromArray(array $data): self\n {\n $task = new self();\n\n if (isset($data['id'])) {\n $task->setId((int) $data['id']);\n }\n\n $task->hydrate($data);\n\n return $task;\n }\n}"
}
}
{
"tool_response": {
"filePath": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Domain\/Entity\/Task.php",
"oldString": " public function toArray(): array\n {\n return [\n 'id' => $this->id,\n 'uuid' => $this->uuid,\n 'title' => $this->title,\n 'description' => $this->description,\n 'type' => $this->type,\n 'status' => $this->status->value,\n 'created_by' => $this->createdBy,\n 'created_by_type' => $this->createdByType,\n 'parent_task_id' => $this->parentTaskId,\n 'due_date' => $this->dueDate?->format('Y-m-d H:i:s'),\n 'created_at' => $this->createdAt->format('Y-m-d H:i:s.u'),\n 'updated_at' => $this->updatedAt->format('Y-m-d H:i:s.u'),\n 'completed_at' => $this->completedAt?->format('Y-m-d H:i:s.u'),\n 'metadata' => $this->metadata,\n ];\n }\n\n public static function fromArray(array $data): self\n {\n $task = new self();\n\n if (isset($data['id'])) {\n $task->setId((int) $data['id']);\n }\n if (isset($data['uuid'])) {\n $task->setUuid($data['uuid']);\n }\n if (isset($data['title'])) {\n $task->setTitle($data['title']);\n }\n if (isset($data['description'])) {\n $task->setDescription($data['description']);\n }\n if (isset($data['type'])) {\n $task->setType($data['type']);\n }\n if (isset($data['status'])) {\n $task->status = TaskStatus::from($data['status']);\n }\n if (isset($data['created_by'])) {\n $task->setCreatedBy($data['created_by']);\n }\n if (isset($data['created_by_type'])) {\n $task->setCreatedByType($data['created_by_type']);\n }\n if (isset($data['parent_task_id'])) {\n $task->setParentTaskId((int) $data['parent_task_id']);\n }\n if (isset($data['due_date'])) {\n $task->setDueDate(new \\DateTimeImmutable($data['due_date']));\n }\n if (isset($data['created_at'])) {\n $task->setCreatedAt(new \\DateTimeImmutable($data['created_at']));\n }\n if (isset($data['updated_at'])) {\n $task->setUpdatedAt(new \\DateTimeImmutable($data['updated_at']));\n }\n if (isset($data['completed_at'])) {\n $task->setCompletedAt(new \\DateTimeImmutable($data['completed_at']));\n }\n if (isset($data['metadata'])) {\n $metadata = is_string($data['metadata']) ? json_decode($data['metadata'], true) : $data['metadata'];\n $task->setMetadata($metadata ?? []);\n }\n\n return $task;\n }\n}",
"newString": " public function toArray(): array\n {\n return [\n 'id' => $this->id,\n 'uuid' => $this->uuid,\n 'title' => $this->title,\n 'description' => $this->description,\n 'type' => $this->type->value,\n 'status' => $this->status->value,\n 'created_by' => $this->createdBy,\n 'created_by_type' => $this->createdByType,\n 'parent_task_id' => $this->parentTaskId,\n 'due_date' => $this->dueDate?->format('Y-m-d H:i:s'),\n 'created_at' => $this->createdAt->format('Y-m-d H:i:s.u'),\n 'updated_at' => $this->updatedAt->format('Y-m-d H:i:s.u'),\n 'completed_at' => $this->completedAt?->format('Y-m-d H:i:s.u'),\n 'metadata' => $this->metadata,\n ];\n }\n\n public static function fromArray(array $data): self\n {\n $task = new self();\n\n if (isset($data['id'])) {\n $task->setId((int) $data['id']);\n }\n\n $task->hydrate($data);\n\n return $task;\n }\n}",
"originalFile": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Domain\\Entity;\n\n\/\/ @responsibility: Task-Entität - Rich Domain Model mit Business-Logik\n\nuse Domain\\ValueObject\\TaskStatus;\nuse Domain\\ValueObject\\TaskType;\n\nclass Task\n{\n private ?int $id = null;\n private string $uuid;\n private string $title;\n private ?string $description = null;\n private TaskType $type;\n private TaskStatus $status;\n private string $createdBy;\n private string $createdByType = 'human';\n private ?int $parentTaskId = null;\n private ?\\DateTimeImmutable $dueDate = null;\n private \\DateTimeImmutable $createdAt;\n private \\DateTimeImmutable $updatedAt;\n private ?\\DateTimeImmutable $completedAt = null;\n private array $metadata = [];\n\n private function __construct()\n {\n $this->uuid = $this->generateUuid();\n $this->status = TaskStatus::PENDING;\n $this->type = TaskType::HUMAN_TASK;\n $this->createdAt = new \\DateTimeImmutable();\n $this->updatedAt = new \\DateTimeImmutable();\n }\n\n public static function create(\n string $title,\n string $createdBy,\n ?string $description = null,\n ?TaskType $type = null,\n ?int $parentTaskId = null,\n ?\\DateTimeImmutable $dueDate = null\n ): self {\n $task = new self();\n $task->title = $title;\n $task->createdBy = $createdBy;\n $task->description = $description;\n\n if ($type !== null) {\n $task->type = $type;\n }\n\n if ($parentTaskId !== null) {\n $task->parentTaskId = $parentTaskId;\n }\n\n if ($dueDate !== null) {\n $task->dueDate = $dueDate;\n }\n\n return $task;\n }\n\n private function generateUuid(): string\n {\n return sprintf(\n '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',\n mt_rand(0, 0xffff),\n mt_rand(0, 0xffff),\n mt_rand(0, 0xffff),\n mt_rand(0, 0x0fff) | 0x4000,\n mt_rand(0, 0x3fff) | 0x8000,\n mt_rand(0, 0xffff),\n mt_rand(0, 0xffff),\n mt_rand(0, 0xffff)\n );\n }\n\n \/\/ Getters\n public function getId(): ?int\n {\n return $this->id;\n }\n\n public function getUuid(): string\n {\n return $this->uuid;\n }\n\n public function getTitle(): string\n {\n return $this->title;\n }\n\n public function getDescription(): ?string\n {\n return $this->description;\n }\n\n public function getType(): TaskType\n {\n return $this->type;\n }\n\n public function getStatus(): TaskStatus\n {\n return $this->status;\n }\n\n public function getCreatedBy(): string\n {\n return $this->createdBy;\n }\n\n public function getCreatedByType(): string\n {\n return $this->createdByType;\n }\n\n public function getParentTaskId(): ?int\n {\n return $this->parentTaskId;\n }\n\n public function getDueDate(): ?\\DateTimeImmutable\n {\n return $this->dueDate;\n }\n\n public function getCreatedAt(): \\DateTimeImmutable\n {\n return $this->createdAt;\n }\n\n public function getUpdatedAt(): \\DateTimeImmutable\n {\n return $this->updatedAt;\n }\n\n public function getCompletedAt(): ?\\DateTimeImmutable\n {\n return $this->completedAt;\n }\n\n public function getMetadata(): array\n {\n return $this->metadata;\n }\n\n \/\/ Business Methods\n public function updateDetails(string $title, ?string $description = null): self\n {\n $this->title = $title;\n $this->description = $description;\n $this->touch();\n\n return $this;\n }\n\n public function changeType(TaskType $type): self\n {\n $this->type = $type;\n $this->touch();\n\n return $this;\n }\n\n public function assignParent(int $parentTaskId): self\n {\n $this->parentTaskId = $parentTaskId;\n $this->touch();\n\n return $this;\n }\n\n public function setDueDateTo(\\DateTimeImmutable $dueDate): self\n {\n $this->dueDate = $dueDate;\n $this->touch();\n\n return $this;\n }\n\n public function clearDueDate(): self\n {\n $this->dueDate = null;\n $this->touch();\n\n return $this;\n }\n\n public function updateMetadata(array $metadata): self\n {\n $this->metadata = $metadata;\n $this->touch();\n\n return $this;\n }\n\n public function isOverdue(): bool\n {\n if ($this->dueDate === null || $this->status->isTerminal()) {\n return false;\n }\n\n return $this->dueDate < new \\DateTimeImmutable();\n }\n\n public function isSubtask(): bool\n {\n return $this->parentTaskId !== null;\n }\n\n \/\/ Status Transitions\n public function start(): self\n {\n $this->transitionTo(TaskStatus::IN_PROGRESS);\n\n return $this;\n }\n\n public function complete(): self\n {\n $this->transitionTo(TaskStatus::COMPLETED);\n\n return $this;\n }\n\n public function fail(): self\n {\n $this->transitionTo(TaskStatus::FAILED);\n\n return $this;\n }\n\n public function cancel(): self\n {\n $this->transitionTo(TaskStatus::CANCELLED);\n\n return $this;\n }\n\n public function retry(): self\n {\n if ($this->status !== TaskStatus::FAILED) {\n throw new \\DomainException('Can only retry failed tasks');\n }\n\n $this->transitionTo(TaskStatus::PENDING);\n $this->completedAt = null;\n\n return $this;\n }\n\n private function transitionTo(TaskStatus $newStatus): void\n {\n if (!$this->status->canTransitionTo($newStatus)) {\n throw new \\DomainException(\n sprintf('Cannot transition from %s to %s', $this->status->value, $newStatus->value)\n );\n }\n\n $this->status = $newStatus;\n $this->touch();\n\n if ($newStatus->isTerminal()) {\n $this->completedAt = new \\DateTimeImmutable();\n }\n }\n\n private function touch(): void\n {\n $this->updatedAt = new \\DateTimeImmutable();\n }\n\n \/\/ Internal Setters for Hydration\n public function setId(int $id): self\n {\n $this->id = $id;\n\n return $this;\n }\n\n public function hydrate(array $data): self\n {\n if (isset($data['uuid'])) {\n $this->uuid = $data['uuid'];\n }\n if (isset($data['title'])) {\n $this->title = $data['title'];\n }\n if (isset($data['description'])) {\n $this->description = $data['description'];\n }\n if (isset($data['type'])) {\n $this->type = is_string($data['type']) ? TaskType::from($data['type']) : $data['type'];\n }\n if (isset($data['status'])) {\n $this->status = is_string($data['status']) ? TaskStatus::from($data['status']) : $data['status'];\n }\n if (isset($data['created_by'])) {\n $this->createdBy = $data['created_by'];\n }\n if (isset($data['created_by_type'])) {\n $this->createdByType = $data['created_by_type'];\n }\n if (isset($data['parent_task_id'])) {\n $this->parentTaskId = (int) $data['parent_task_id'];\n }\n if (isset($data['due_date'])) {\n $this->dueDate = $data['due_date'] instanceof \\DateTimeImmutable\n ? $data['due_date']\n : new \\DateTimeImmutable($data['due_date']);\n }\n if (isset($data['created_at'])) {\n $this->createdAt = $data['created_at'] instanceof \\DateTimeImmutable\n ? $data['created_at']\n : new \\DateTimeImmutable($data['created_at']);\n }\n if (isset($data['updated_at'])) {\n $this->updatedAt = $data['updated_at'] instanceof \\DateTimeImmutable\n ? $data['updated_at']\n : new \\DateTimeImmutable($data['updated_at']);\n }\n if (isset($data['completed_at'])) {\n $this->completedAt = $data['completed_at'] instanceof \\DateTimeImmutable\n ? $data['completed_at']\n : new \\DateTimeImmutable($data['completed_at']);\n }\n if (isset($data['metadata'])) {\n $this->metadata = is_string($data['metadata']) ? json_decode($data['metadata'], true) : $data['metadata'];\n }\n\n return $this;\n }\n\n public function toArray(): array\n {\n return [\n 'id' => $this->id,\n 'uuid' => $this->uuid,\n 'title' => $this->title,\n 'description' => $this->description,\n 'type' => $this->type,\n 'status' => $this->status->value,\n 'created_by' => $this->createdBy,\n 'created_by_type' => $this->createdByType,\n 'parent_task_id' => $this->parentTaskId,\n 'due_date' => $this->dueDate?->format('Y-m-d H:i:s'),\n 'created_at' => $this->createdAt->format('Y-m-d H:i:s.u'),\n 'updated_at' => $this->updatedAt->format('Y-m-d H:i:s.u'),\n 'completed_at' => $this->completedAt?->format('Y-m-d H:i:s.u'),\n 'metadata' => $this->metadata,\n ];\n }\n\n public static function fromArray(array $data): self\n {\n $task = new self();\n\n if (isset($data['id'])) {\n $task->setId((int) $data['id']);\n }\n if (isset($data['uuid'])) {\n $task->setUuid($data['uuid']);\n }\n if (isset($data['title'])) {\n $task->setTitle($data['title']);\n }\n if (isset($data['description'])) {\n $task->setDescription($data['description']);\n }\n if (isset($data['type'])) {\n $task->setType($data['type']);\n }\n if (isset($data['status'])) {\n $task->status = TaskStatus::from($data['status']);\n }\n if (isset($data['created_by'])) {\n $task->setCreatedBy($data['created_by']);\n }\n if (isset($data['created_by_type'])) {\n $task->setCreatedByType($data['c... [TRUNCATED-dce00a444091eb2a]",
"structuredPatch": [
{
"oldStart": 343,
"oldLines": 7,
"newStart": 343,
"newLines": 7,
"lines": [
" 'uuid' => $this->uuid,",
" 'title' => $this->title,",
" 'description' => $this->description,",
"- 'type' => $this->type,",
"+ 'type' => $this->type->value,",
" 'status' => $this->status->value,",
" 'created_by' => $this->createdBy,",
" 'created_by_type' => $this->createdByType,"
]
},
{
"oldStart": 363,
"oldLines": 47,
"newStart": 363,
"newLines": 9,
"lines": [
" if (isset($data['id'])) {",
" $task->setId((int) $data['id']);",
" }",
"- if (isset($data['uuid'])) {",
"- $task->setUuid($data['uuid']);",
"- }",
"- if (isset($data['title'])) {",
"- $task->setTitle($data['title']);",
"- }",
"- if (isset($data['description'])) {",
"- $task->setDescription($data['description']);",
"- }",
"- if (isset($data['type'])) {",
"- $task->setType($data['type']);",
"- }",
"- if (isset($data['status'])) {",
"- $task->status = TaskStatus::from($data['status']);",
"- }",
"- if (isset($data['created_by'])) {",
"- $task->setCreatedBy($data['created_by']);",
"- }",
"- if (isset($data['created_by_type'])) {",
"- $task->setCreatedByType($data['created_by_type']);",
"- }",
"- if (isset($data['parent_task_id'])) {",
"- $task->setParentTaskId((int) $data['parent_task_id']);",
"- }",
"- if (isset($data['due_date'])) {",
"- $task->setDueDate(new \\DateTimeImmutable($data['due_date']));",
"- }",
"- if (isset($data['created_at'])) {",
"- $task->setCreatedAt(new \\DateTimeImmutable($data['created_at']));",
"- }",
"- if (isset($data['updated_at'])) {",
"- $task->setUpdatedAt(new \\DateTimeImmutable($data['updated_at']));",
"- }",
"- if (isset($data['completed_at'])) {",
"- $task->setCompletedAt(new \\DateTimeImmutable($data['completed_at']));",
"- }",
"- if (isset($data['metadata'])) {",
"- $metadata = is_string($data['metadata']) ? json_decode($data['metadata'], true) : $data['metadata'];",
"- $task->setMetadata($metadata ?? []);",
"- }",
" ",
"+ $task->hydrate($data);",
"+",
" return $task;",
" }",
" }"
]
}
],
"userModified": false,
"replaceAll": false
}
}