{
"event": "PreToolUse",
"tool_name": "Write",
"tool_input": {
"file_path": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Domain\/Factory\/ChatSessionFactory.php",
"content": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Domain\\Factory;\n\n\/\/ @responsibility: Factory für ChatSession-Erstellung und Hydration\n\nuse Domain\\Entity\\ChatSession;\nuse Domain\\ValueObject\\SessionMetadata;\nuse Domain\\ValueObject\\SessionUuid;\n\nfinal class ChatSessionFactory\n{\n \/**\n * Erstelle neue Session mit Defaults.\n *\/\n public static function createNew(\n ?SessionUuid $uuid = null,\n ?SessionMetadata $metadata = null\n ): ChatSession {\n return new ChatSession(\n uuid: $uuid ?? SessionUuid::generate(),\n metadata: $metadata ?? SessionMetadata::create()\n );\n }\n\n \/**\n * Erstelle Session aus Datenbank-Row.\n *\n * @param array<string, mixed> $data\n *\/\n public static function fromArray(array $data): ChatSession\n {\n $collections = self::parseCollections($data['collections'] ?? '[\"documents\"]');\n\n $metadata = SessionMetadata::create(\n model: $data['model'] ?? 'claude-opus-4-5-20251101',\n collections: $collections,\n contextLimit: (int) ($data['context_limit'] ?? 5),\n temperature: (float) ($data['temperature'] ?? 0.7),\n maxTokens: (int) ($data['max_tokens'] ?? 4096)\n );\n\n $session = new ChatSession(\n uuid: SessionUuid::fromString($data['uuid']),\n metadata: $metadata,\n id: isset($data['id']) ? (int) $data['id'] : null,\n sessionToken: $data['session_token'] ?? null,\n userId: isset($data['user_id']) ? (int) $data['user_id'] : null,\n personaId: isset($data['persona_id']) ? (int) $data['persona_id'] : null,\n title: $data['title'] ?? null,\n authorProfileId: isset($data['author_profile_id']) ? (int) $data['author_profile_id'] : null,\n systemPromptId: isset($data['system_prompt_id']) ? (int) $data['system_prompt_id'] : null,\n createdAt: isset($data['created_at']) ? new \\DateTimeImmutable($data['created_at']) : new \\DateTimeImmutable(),\n updatedAt: isset($data['updated_at']) ? new \\DateTimeImmutable($data['updated_at']) : new \\DateTimeImmutable(),\n lastActivity: isset($data['last_activity']) ? new \\DateTimeImmutable($data['last_activity']) : new \\DateTimeImmutable()\n );\n\n return $session;\n }\n\n \/**\n * Parse collections from JSON string or array.\n *\n * @return array<string>\n *\/\n private static function parseCollections(mixed $collections): array\n {\n if (is_string($collections)) {\n $decoded = json_decode($collections, true);\n\n return is_array($decoded) ? $decoded : ['documents'];\n }\n\n if (is_array($collections)) {\n return $collections;\n }\n\n return ['documents'];\n }\n}\n"
}
}