Skip to content

Commit 44414e4

Browse files
feat: refactor to remove early return
1 parent cb00da1 commit 44414e4

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/Events/LivewireDispatcher.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,12 @@ public function register(): void
1616
}
1717

1818
/** Injects assets inside every full-page response */
19-
public function handle(RequestHandled $handled)
19+
public function handle(RequestHandled $handled): void
2020
{
2121
$identifier = 'NativePHP Livewire Dispatcher';
2222
$html = $handled->response->getContent();
2323
$originalContent = $handled->response->original ?? null;
2424

25-
if (! $originalContent) {
26-
return;
27-
}
28-
2925
if (! $handled->response->isSuccessful()) {
3026
return;
3127
}
@@ -54,7 +50,9 @@ public function handle(RequestHandled $handled)
5450
HTML)
5551
);
5652

57-
$handled->response->original = $originalContent;
53+
if (property_exists($handled->response, 'original')) {
54+
$handled->response->original = $originalContent;
55+
}
5856
}
5957

6058
/** Injects assets into given html string (taken from Livewire's injection mechanism) */

0 commit comments

Comments
 (0)