Skip to content

Commit 88b00ba

Browse files
committed
simplify app call detection logic
1 parent 4be6289 commit 88b00ba

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/Response.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -209,15 +209,16 @@ public function resolveAlways(array $props): array
209209
public function resolvePropertyInstances(array $props, Request $request): array
210210
{
211211
foreach ($props as $key => $value) {
212-
if ($value instanceof Closure) {
213-
$value = App::call($value);
214-
}
215-
216-
if ($value instanceof LazyProp || $value instanceof OptionalProp || $value instanceof DeferProp) {
217-
$value = App::call($value);
218-
}
219-
220-
if ($value instanceof AlwaysProp) {
212+
$resolveViaApp = collect([
213+
Closure::class,
214+
LazyProp::class,
215+
OptionalProp::class,
216+
DeferProp::class,
217+
AlwaysProp::class,
218+
WhenVisible::class,
219+
])->first(fn ($class) => $value instanceof $class);
220+
221+
if ($resolveViaApp) {
221222
$value = App::call($value);
222223
}
223224

0 commit comments

Comments
 (0)