{
"tool_response": {
"filePath": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Domain\/Entity\/Task.php",
"oldString": " 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 \/** @return array<string, mixed> *\/\n public function getMetadata(): array\n {\n return $this->metadata;\n }",
"newString": " public function getId(): ?int { return $this->id; }\n public function getUuid(): string { return $this->uuid; }\n public function getTitle(): string { return $this->title; }\n public function getDescription(): ?string { return $this->description; }\n public function getType(): TaskType { return $this->type; }\n public function getStatus(): TaskStatus { return $this->status; }\n public function getCreatedBy(): string { return $this->createdBy; }\n public function getCreatedByType(): string { return $this->createdByType; }\n public function getParentTaskId(): ?int { return $this->parentTaskId; }\n public function getDueDate(): ?\\DateTimeImmutable { return $this->dueDate; }\n public function getCreatedAt(): \\DateTimeImmutable { return $this->createdAt; }\n public function getUpdatedAt(): \\DateTimeImmutable { return $this->updatedAt; }\n public function getCompletedAt(): ?\\DateTimeImmutable { return $this->completedAt; }\n \/** @return array<string, mixed> *\/\n public function getMetadata(): array { return $this->metadata; }",
"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 \/** @var array<string, mixed> *\/\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 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 \/** @return array<string, mixed> *\/\n public function getMetadata(): array\n {\n return $this->metadata;\n }\n\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 \/** @param array<string, mixed> $metadata *\/\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 return $this->dueDate !== null\n && !$this->status->isTerminal()\n && $this->dueDate < new \\DateTimeImmutable();\n }\n\n public function isSubtask(): bool\n {\n return $this->parentTaskId !== null;\n }\n\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 $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 $this->status = $newStatus;\n $this->touch();\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 public function setId(int $id): self\n {\n $this->id = $id;\n\n return $this;\n }\n\n \/** @param array<string, mixed> $data *\/\n public function hydrate(array $data): self\n {\n $this->uuid = $data['uuid'] ?? $this->uuid;\n $this->title = $data['title'] ?? $this->title;\n $this->description = $data['description'] ?? null;\n $this->createdBy = $data['created_by'] ?? $this->createdBy;\n $this->createdByType = $data['created_by_type'] ?? 'human';\n $this->parentTaskId = isset($data['parent_task_id']) ? (int) $data['parent_task_id'] : null;\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['due_date'])) {\n $this->dueDate = $this->toDateTime($data['due_date']);\n }\n if (isset($data['created_at'])) {\n $this->createdAt = $this->toDateTime($data['created_at']);\n }\n if (isset($data['updated_at'])) {\n $this->updatedAt = $this->toDateTime($data['updated_at']);\n }\n if (isset($data['completed_at'])) {\n $this->completedAt = $this->toDateTime($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 private function toDateTime(\\DateTimeImmutable|string $value): \\DateTimeImmutable\n {\n return $value instanceof \\DateTimeImmutable ? $value : new \\DateTimeImmutable($value);\n }\n\n \/** @return array<string, mixed> *\/\n public function toArray(): array\n {\n return [\n 'id' => $this->id, 'uuid' => $this->uuid, 'title' => $this->title,\n 'description' => $this->description, 'type' => $this->type->value,\n 'status' => $this->status->value, 'created_by' => $this->createdBy,\n 'created_by_type' => $this->createdByType, '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 \/** @param array<string, mixed> $data *\/\n public static function fromArray(array $data): self\n {\n $task = new self();\n if (isset($data['id'])) {\n $task->setId((int) $data['id']);\n }\n\n return $task->hydrate($data);\n }\n}\n",
"structuredPatch": [
{
"oldStart": 79,
"oldLines": 76,
"newStart": 79,
"newLines": 21,
"lines": [
" );",
" }",
" ",
"- public function getId(): ?int",
"- {",
"- return $this->id;",
"- }",
"-",
"- public function getUuid(): string",
"- {",
"- return $this->uuid;",
"- }",
"-",
"- public function getTitle(): string",
"- {",
"- return $this->title;",
"- }",
"-",
"- public function getDescription(): ?string",
"- {",
"- return $this->description;",
"- }",
"-",
"- public function getType(): TaskType",
"- {",
"- return $this->type;",
"- }",
"-",
"- public function getStatus(): TaskStatus",
"- {",
"- return $this->status;",
"- }",
"-",
"- public function getCreatedBy(): string",
"- {",
"- return $this->createdBy;",
"- }",
"-",
"- public function getCreatedByType(): string",
"- {",
"- return $this->createdByType;",
"- }",
"-",
"- public function getParentTaskId(): ?int",
"- {",
"- return $this->parentTaskId;",
"- }",
"-",
"- public function getDueDate(): ?\\DateTimeImmutable",
"- {",
"- return $this->dueDate;",
"- }",
"-",
"- public function getCreatedAt(): \\DateTimeImmutable",
"- {",
"- return $this->createdAt;",
"- }",
"-",
"- public function getUpdatedAt(): \\DateTimeImmutable",
"- {",
"- return $this->updatedAt;",
"- }",
"-",
"- public function getCompletedAt(): ?\\DateTimeImmutable",
"- {",
"- return $this->completedAt;",
"- }",
"-",
"+ public function getId(): ?int { return $this->id; }",
"+ public function getUuid(): string { return $this->uuid; }",
"+ public function getTitle(): string { return $this->title; }",
"+ public function getDescription(): ?string { return $this->description; }",
"+ public function getType(): TaskType { return $this->type; }",
"+ public function getStatus(): TaskStatus { return $this->status; }",
"+ public function getCreatedBy(): string { return $this->createdBy; }",
"+ public function getCreatedByType(): string { return $this->createdByType; }",
"+ public function getParentTaskId(): ?int { return $this->parentTaskId; }",
"+ public function getDueDate(): ?\\DateTimeImmutable { return $this->dueDate; }",
"+ public function getCreatedAt(): \\DateTimeImmutable { return $this->createdAt; }",
"+ public function getUpdatedAt(): \\DateTimeImmutable { return $this->updatedAt; }",
"+ public function getCompletedAt(): ?\\DateTimeImmutable { return $this->completedAt; }",
" \/** @return array<string, mixed> *\/",
"- public function getMetadata(): array",
"- {",
"- return $this->metadata;",
"- }",
"+ public function getMetadata(): array { return $this->metadata; }",
" ",
" public function updateDetails(string $title, ?string $description = null): self",
" {"
]
}
],
"userModified": false,
"replaceAll": false
}
}