From 41974df6cc25063829078bc187f1306b0d7393f3 Mon Sep 17 00:00:00 2001 From: Krishan Koenig Date: Fri, 10 Jan 2025 09:53:45 +0100 Subject: [PATCH] wip --- src/GithubIssueFormatter.php | 14 +++++++------- src/GithubIssueLoggerHandler.php | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/GithubIssueFormatter.php b/src/GithubIssueFormatter.php index 3215369..2b92fe2 100644 --- a/src/GithubIssueFormatter.php +++ b/src/GithubIssueFormatter.php @@ -57,11 +57,11 @@ private function generateSignature(LogRecord $record, ?Throwable $exception): st get_class($exception), $exception->getFile(), $exception->getLine(), - $firstFrame ? ($firstFrame['file'] ?? '').':'.($firstFrame['line'] ?? '') : '', + $firstFrame ? ($firstFrame['file'] ?? '') . ':' . ($firstFrame['line'] ?? '') : '', ])); } - return md5($record->message.json_encode($record->context)); + return md5($record->message . json_encode($record->context)); } /** @@ -92,7 +92,7 @@ private function formatTitle(LogRecord $record, ?Throwable $exception = null): s ->replace('{level}', $record->level->getName()) ->replace('{class}', $exceptionClass) ->replace('{file}', $file) - ->replace('{line}', $exception->getLine()) + ->replace('{line}', (string) $exception->getLine()) ->replace('{message}', Str::limit($exception->getMessage(), self::TITLE_MAX_LENGTH)) ->toString(); } @@ -117,11 +117,11 @@ private function formatBody(LogRecord $record, string $signature, ?Throwable $ex $previousExceptions = $this->formatPreviousExceptions($exception); $body .= $this->renderPreviousExceptions($previousExceptions); } elseif (! empty($record->context)) { - $body .= "**Context:**\n```json\n".json_encode($record->context, JSON_PRETTY_PRINT)."\n```\n\n"; + $body .= "**Context:**\n```json\n" . json_encode($record->context, JSON_PRETTY_PRINT) . "\n```\n\n"; } if (! empty($record->extra)) { - $body .= "**Extra Data:**\n```json\n".json_encode($record->extra, JSON_PRETTY_PRINT)."\n```\n"; + $body .= "**Extra Data:**\n```json\n" . json_encode($record->extra, JSON_PRETTY_PRINT) . "\n```\n"; } $body .= "\n\n"; @@ -228,11 +228,11 @@ public function formatComment(LogRecord $record, ?Throwable $exception): string $previousExceptions = $this->formatPreviousExceptions($exception); $body .= $this->renderPreviousExceptions($previousExceptions, true); } elseif (! empty($record->context)) { - $body .= "**Context:**\n```json\n".json_encode($record->context, JSON_PRETTY_PRINT)."\n```\n\n"; + $body .= "**Context:**\n```json\n" . json_encode($record->context, JSON_PRETTY_PRINT) . "\n```\n\n"; } if (! empty($record->extra)) { - $body .= "**Extra Data:**\n```json\n".json_encode($record->extra, JSON_PRETTY_PRINT)."\n```\n"; + $body .= "**Extra Data:**\n```json\n" . json_encode($record->extra, JSON_PRETTY_PRINT) . "\n```\n"; } return $body; diff --git a/src/GithubIssueLoggerHandler.php b/src/GithubIssueLoggerHandler.php index c7f2f49..45d9b88 100644 --- a/src/GithubIssueLoggerHandler.php +++ b/src/GithubIssueLoggerHandler.php @@ -66,11 +66,11 @@ private function findExistingIssue(string $signature): ?array { $response = Http::withToken($this->token) ->get('https://api.github.com/search/issues', [ - 'q' => "repo:{$this->repo} is:issue is:open label:".static::DEFAULT_LABEL." \"Signature: {$signature}\"", + 'q' => "repo:{$this->repo} is:issue is:open label:" . self::DEFAULT_LABEL . " \"Signature: {$signature}\"", ]); if ($response->failed()) { - throw new \RuntimeException('Failed to search GitHub issues: '.$response->body()); + throw new \RuntimeException('Failed to search GitHub issues: ' . $response->body()); } return $response->json('items.0', null); @@ -87,7 +87,7 @@ private function commentOnIssue(int $issueNumber, GithubIssueFormatted $formatte ]); if ($response->failed()) { - throw new \RuntimeException('Failed to comment on GitHub issue: '.$response->body()); + throw new \RuntimeException('Failed to comment on GitHub issue: ' . $response->body()); } } @@ -104,7 +104,7 @@ private function createIssue(GithubIssueFormatted $formatted): void ]); if ($response->failed()) { - throw new \RuntimeException('Failed to create GitHub issue: '.$response->body()); + throw new \RuntimeException('Failed to create GitHub issue: ' . $response->body()); } } }