Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 48 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| ErrorLogData | |
0.00% |
0 / 48 |
|
0.00% |
0 / 2 |
56 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 23 |
|
0.00% |
0 / 1 |
42 | |||
| jsonSerialize | |
0.00% |
0 / 25 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace App\Domain\ErrorLog\Data; |
| 6 | |
| 7 | use JsonSerializable; |
| 8 | |
| 9 | /** |
| 10 | * Data transfer object for error log entries. |
| 11 | */ |
| 12 | final class ErrorLogData implements JsonSerializable |
| 13 | { |
| 14 | public int $errorId; |
| 15 | |
| 16 | public string $level; |
| 17 | |
| 18 | public int $levelValue; |
| 19 | |
| 20 | public ?string $errorCode; |
| 21 | |
| 22 | public string $message; |
| 23 | |
| 24 | public ?string $stackTrace; |
| 25 | |
| 26 | public ?string $requestUri; |
| 27 | |
| 28 | public ?string $requestMethod; |
| 29 | |
| 30 | public ?int $userId; |
| 31 | |
| 32 | public ?string $username; |
| 33 | |
| 34 | public ?string $userEmail; |
| 35 | |
| 36 | public ?int $sessionId; |
| 37 | |
| 38 | public ?string $sessionCreatedAt; |
| 39 | |
| 40 | public ?string $ipAddress; |
| 41 | |
| 42 | public ?string $userAgent; |
| 43 | |
| 44 | /** @var array<string, mixed>|null */ |
| 45 | public ?array $requestBody; |
| 46 | |
| 47 | /** @var array<string, mixed>|null */ |
| 48 | public ?array $context; |
| 49 | |
| 50 | public ?string $resolvedAt; |
| 51 | |
| 52 | public ?int $resolvedBy; |
| 53 | |
| 54 | public ?string $resolvedByUsername; |
| 55 | |
| 56 | public ?string $resolutionNotes; |
| 57 | |
| 58 | public string $createdAt; |
| 59 | |
| 60 | public bool $isResolved; |
| 61 | |
| 62 | /** |
| 63 | * @param array<string, mixed> $data |
| 64 | */ |
| 65 | public function __construct(array $data) |
| 66 | { |
| 67 | $this->errorId = (int)$data['errorId']; |
| 68 | $this->level = $data['level']; |
| 69 | $this->levelValue = (int)$data['levelValue']; |
| 70 | $this->errorCode = $data['errorCode'] ?? null; |
| 71 | $this->message = $data['message']; |
| 72 | $this->stackTrace = $data['stackTrace'] ?? null; |
| 73 | $this->requestUri = $data['requestUri'] ?? null; |
| 74 | $this->requestMethod = $data['requestMethod'] ?? null; |
| 75 | $this->userId = isset($data['userId']) ? (int)$data['userId'] : null; |
| 76 | $this->username = $data['username'] ?? null; |
| 77 | $this->userEmail = $data['userEmail'] ?? null; |
| 78 | $this->sessionId = isset($data['sessionId']) ? (int)$data['sessionId'] : null; |
| 79 | $this->sessionCreatedAt = $data['sessionCreatedAt'] ?? null; |
| 80 | $this->ipAddress = $data['ipAddress'] ?? null; |
| 81 | $this->userAgent = $data['userAgent'] ?? null; |
| 82 | $this->requestBody = isset($data['requestBody']) ? (array)$data['requestBody'] : null; |
| 83 | $this->context = isset($data['context']) ? (array)$data['context'] : null; |
| 84 | $this->resolvedAt = $data['resolvedAt'] ?? null; |
| 85 | $this->resolvedBy = isset($data['resolvedBy']) ? (int)$data['resolvedBy'] : null; |
| 86 | $this->resolvedByUsername = $data['resolvedByUsername'] ?? null; |
| 87 | $this->resolutionNotes = $data['resolutionNotes'] ?? null; |
| 88 | $this->createdAt = $data['createdAt']; |
| 89 | $this->isResolved = (bool)($data['isResolved'] ?? false); |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * @return array<string, mixed> |
| 94 | */ |
| 95 | public function jsonSerialize(): array |
| 96 | { |
| 97 | return [ |
| 98 | 'errorId' => $this->errorId, |
| 99 | 'level' => $this->level, |
| 100 | 'levelValue' => $this->levelValue, |
| 101 | 'errorCode' => $this->errorCode, |
| 102 | 'message' => $this->message, |
| 103 | 'stackTrace' => $this->stackTrace, |
| 104 | 'requestUri' => $this->requestUri, |
| 105 | 'requestMethod' => $this->requestMethod, |
| 106 | 'userId' => $this->userId, |
| 107 | 'username' => $this->username, |
| 108 | 'userEmail' => $this->userEmail, |
| 109 | 'sessionId' => $this->sessionId, |
| 110 | 'sessionCreatedAt' => $this->sessionCreatedAt, |
| 111 | 'ipAddress' => $this->ipAddress, |
| 112 | 'userAgent' => $this->userAgent, |
| 113 | 'requestBody' => $this->requestBody, |
| 114 | 'context' => $this->context, |
| 115 | 'resolvedAt' => $this->resolvedAt, |
| 116 | 'resolvedBy' => $this->resolvedBy, |
| 117 | 'resolvedByUsername' => $this->resolvedByUsername, |
| 118 | 'resolutionNotes' => $this->resolutionNotes, |
| 119 | 'createdAt' => $this->createdAt, |
| 120 | 'isResolved' => $this->isResolved, |
| 121 | ]; |
| 122 | } |
| 123 | } |