Skip to content

Commit

Permalink
simplify app call detection logic
Browse files Browse the repository at this point in the history
  • Loading branch information
joetannenbaum committed Jul 18, 2024
1 parent 4be6289 commit 88b00ba
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,16 @@ public function resolveAlways(array $props): array
public function resolvePropertyInstances(array $props, Request $request): array
{
foreach ($props as $key => $value) {
if ($value instanceof Closure) {
$value = App::call($value);
}

if ($value instanceof LazyProp || $value instanceof OptionalProp || $value instanceof DeferProp) {
$value = App::call($value);
}

if ($value instanceof AlwaysProp) {
$resolveViaApp = collect([
Closure::class,
LazyProp::class,
OptionalProp::class,
DeferProp::class,
AlwaysProp::class,
WhenVisible::class,
])->first(fn ($class) => $value instanceof $class);

if ($resolveViaApp) {
$value = App::call($value);
}

Expand Down

0 comments on commit 88b00ba

Please sign in to comment.