Protokoll #4963
| ID | 4963 |
|---|---|
| Zeitstempel | 2025-12-22 15:46:41.058664 |
| Client | root |
| IP | Warning: Undefined array key "request_ip" in /var/www/dev.campus.systemische-tools.de/src/View/protokoll/show.php on line 13 Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/dev.campus.systemische-tools.de/src/View/protokoll/show.php on line 13 |
| Modell | claude-sonnet-4-20250514 |
| Status | completed |
| Tokens | 2,083 (Input: 0, Output: 0) |
| Dauer | 85 ms |
| Request-Zeit | Warning: Undefined array key "request_timestamp" in /var/www/dev.campus.systemische-tools.de/src/View/protokoll/show.php on line 18 |
| Response-Zeit | - |
Warning: Undefined array key "error_message" in /var/www/dev.campus.systemische-tools.de/src/View/protokoll/show.php on line 22
Request
{
"event": "PreToolUse",
"tool_name": "Write",
"tool_input": {
"file_path": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Infrastructure\/Formatter\/ApiResponseFormatter.php",
"content": "<?php\n\nnamespace Infrastructure\\Formatter;\n\n\/**\n * Formats API responses with a consistent structure.\n *\n * Success response:\n * {\n * \"success\": true,\n * \"data\": {...},\n * \"message\": \"optional message\",\n * \"meta\": {\"timestamp\": \"...\", \"count\": N}\n * }\n *\n * Error response:\n * {\n * \"success\": false,\n * \"error\": \"error message\",\n * \"code\": \"ERROR_CODE\",\n * \"details\": {...}\n * }\n *\/\nfinal class ApiResponseFormatter\n{\n \/**\n * Format a success response.\n *\n * @param mixed $data The response data\n * @param string|null $message Optional success message\n * @param array<string, mixed> $meta Optional metadata (pagination, counts, etc.)\n * @return array<string, mixed>\n *\/\n public function success(mixed $data, ?string $message = null, array $meta = []): array\n {\n $response = [\n 'success' => true,\n 'data' => $data,\n ];\n\n if ($message !== null) {\n $response['message'] = $message;\n }\n\n if ($meta !== []) {\n $response['meta'] = $meta;\n }\n\n return $response;\n }\n\n \/**\n * Format a list response with pagination metadata.\n *\n * @param array<mixed> $items The list items\n * @param int $total Total count (for pagination)\n * @param int $page Current page\n * @param int $limit Items per page\n * @return array<string, mixed>\n *\/\n public function list(array $items, int $total, int $page = 1, int $limit = 10): array\n {\n return $this->success($items, null, [\n 'total' => $total,\n 'page' => $page,\n 'limit' => $limit,\n 'pages' => (int) ceil($total \/ max(1, $limit)),\n ]);\n }\n\n \/**\n * Format an error response.\n *\n * @param string $message Error message\n * @param string|null $code Machine-readable error code\n * @param array<string, mixed>|null $details Additional error details\n * @return array<string, mixed>\n *\/\n public function error(string $message, ?string $code = null, ?array $details = null): array\n {\n $response = [\n 'success' => false,\n 'error' => $message,\n ];\n\n if ($code !== null) {\n $response['code'] = $code;\n }\n\n if ($details !== null) {\n $response['details'] = $details;\n }\n\n return $response;\n }\n\n \/**\n * Format a not found error.\n *\n * @param string $resource The resource type that was not found\n * @return array<string, mixed>\n *\/\n public function notFound(string $resource = 'Resource'): array\n {\n return $this->error(\"{$resource} nicht gefunden\", 'NOT_FOUND');\n }\n\n \/**\n * Format a validation error.\n *\n * @param string $message Error message\n * @param array<string, string> $fieldErrors Field-specific errors\n * @return array<string, mixed>\n *\/\n public function validationError(string $message, array $fieldErrors = []): array\n {\n return $this->error($message, 'VALIDATION_ERROR', $fieldErrors !== [] ? ['fields' => $fieldErrors] : null);\n }\n\n \/**\n * Format a created response with the new resource ID.\n *\n * @param int|string $id The created resource ID\n * @param string|null $message Optional success message\n * @return array<string, mixed>\n *\/\n public function created(int|string $id, ?string $message = null): array\n {\n return $this->success(['id' => $id], $message ?? 'Erfolgreich erstellt');\n }\n\n \/**\n * Format a deleted\/updated confirmation.\n *\n * @param string|null $message Optional message\n * @return array<string, mixed>\n *\/\n public function ok(?string $message = null): array\n {\n return $this->success(null, $message);\n }\n}\n"
}
}
Response
{
"tool_response": {
"type": "create",
"filePath": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Infrastructure\/Formatter\/ApiResponseFormatter.php",
"content": "<?php\n\nnamespace Infrastructure\\Formatter;\n\n\/**\n * Formats API responses with a consistent structure.\n *\n * Success response:\n * {\n * \"success\": true,\n * \"data\": {...},\n * \"message\": \"optional message\",\n * \"meta\": {\"timestamp\": \"...\", \"count\": N}\n * }\n *\n * Error response:\n * {\n * \"success\": false,\n * \"error\": \"error message\",\n * \"code\": \"ERROR_CODE\",\n * \"details\": {...}\n * }\n *\/\nfinal class ApiResponseFormatter\n{\n \/**\n * Format a success response.\n *\n * @param mixed $data The response data\n * @param string|null $message Optional success message\n * @param array<string, mixed> $meta Optional metadata (pagination, counts, etc.)\n * @return array<string, mixed>\n *\/\n public function success(mixed $data, ?string $message = null, array $meta = []): array\n {\n $response = [\n 'success' => true,\n 'data' => $data,\n ];\n\n if ($message !== null) {\n $response['message'] = $message;\n }\n\n if ($meta !== []) {\n $response['meta'] = $meta;\n }\n\n return $response;\n }\n\n \/**\n * Format a list response with pagination metadata.\n *\n * @param array<mixed> $items The list items\n * @param int $total Total count (for pagination)\n * @param int $page Current page\n * @param int $limit Items per page\n * @return array<string, mixed>\n *\/\n public function list(array $items, int $total, int $page = 1, int $limit = 10): array\n {\n return $this->success($items, null, [\n 'total' => $total,\n 'page' => $page,\n 'limit' => $limit,\n 'pages' => (int) ceil($total \/ max(1, $limit)),\n ]);\n }\n\n \/**\n * Format an error response.\n *\n * @param string $message Error message\n * @param string|null $code Machine-readable error code\n * @param array<string, mixed>|null $details Additional error details\n * @return array<string, mixed>\n *\/\n public function error(string $message, ?string $code = null, ?array $details = null): array\n {\n $response = [\n 'success' => false,\n 'error' => $message,\n ];\n\n if ($code !== null) {\n $response['code'] = $code;\n }\n\n if ($details !== null) {\n $response['details'] = $details;\n }\n\n return $response;\n }\n\n \/**\n * Format a not found error.\n *\n * @param string $resource The resource type that was not found\n * @return array<string, mixed>\n *\/\n public function notFound(string $resource = 'Resource'): array\n {\n return $this->error(\"{$resource} nicht gefunden\", 'NOT_FOUND');\n }\n\n \/**\n * Format a validation error.\n *\n * @param string $message Error message\n * @param array<string, string> $fieldErrors Field-specific errors\n * @return array<string, mixed>\n *\/\n public function validationError(string $message, array $fieldErrors = []): array\n {\n return $this->error($message, 'VALIDATION_ERROR', $fieldErrors !== [] ? ['fields' => $fieldErrors] : null);\n }\n\n \/**\n * Format a created response with the new resource ID.\n *\n * @param int|string $id The created resource ID\n * @param string|null $message Optional success message\n * @return array<string, mixed>\n *\/\n public function created(int|string $id, ?string $message = null): array\n {\n return $this->success(['id' => $id], $message ?? 'Erfolgreich erstellt');\n }\n\n \/**\n * Format a deleted\/updated confirmation.\n *\n * @param string|null $message Optional message\n * @return array<string, mixed>\n *\/\n public function ok(?string $message = null): array\n {\n return $this->success(null, $message);\n }\n}\n",
"structuredPatch": [],
"originalFile": null
}
}