Skip to content

Commit 6f3fe5d

Browse files
committed
Refactor browser logging methods to static
1 parent 5bdf739 commit 6f3fe5d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/BoostServiceProvider.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ private function registerRoutes(): void
107107
* } $log */
108108
foreach ($logs as $log) {
109109
$logger->write(
110-
level: $this->mapJsTypeToPsr3Level($log['type']),
111-
message: $this->buildLogMessageFromData($log['data']),
110+
level: self::mapJsTypeToPsr3Level($log['type']),
111+
message: self::buildLogMessageFromData($log['data']),
112112
context: [
113113
'url' => $log['url'],
114114
'user_agent' => $log['userAgent'] ?: null,
@@ -127,13 +127,13 @@ private function registerRoutes(): void
127127
* Build a string message for the log based on various input types. Single-dimensional, and multi:
128128
* "data": {"message":"Unhandled Promise Rejection","reason":{"name":"TypeError","message":"NetworkError when attempting to fetch resource.","stack":""}}]
129129
*/
130-
private function buildLogMessageFromData(array $data): string
130+
private static function buildLogMessageFromData(array $data): string
131131
{
132132
$messages = [];
133133

134134
foreach ($data as $value) {
135135
$messages[] = match (true) {
136-
is_array($value) => $this->buildLogMessageFromData($value),
136+
is_array($value) => self::buildLogMessageFromData($value),
137137
is_string($value), is_numeric($value) => (string) $value,
138138
is_bool($value) => $value ? 'true' : 'false',
139139
is_null($value) => 'null',
@@ -162,7 +162,7 @@ private function registerBladeDirectives(BladeCompiler $bladeCompiler): void
162162
$bladeCompiler->directive('boostJs', fn () => '<?php echo \\Laravel\\Boost\\Services\\BrowserLogger::getScript(); ?>');
163163
}
164164

165-
private function mapJsTypeToPsr3Level(string $type): string
165+
private static function mapJsTypeToPsr3Level(string $type): string
166166
{
167167
return match ($type) {
168168
'warn' => 'warning',

0 commit comments

Comments
 (0)