Skip to content

Commit 207a857

Browse files
committed
refactor(core): simplify resolveViewComponent method
1 parent 65a1c01 commit 207a857

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

src/Tempest/Framework/Commands/MetaViewComponentCommand.php

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,13 @@ private function makeData(ViewComponent $viewComponent): ImmutableArray
6060
private function resolveViewComponent(string $viewComponent): ?ViewComponent
6161
{
6262
if (is_file($viewComponent)) {
63-
foreach ($this->viewConfig->viewComponents as $registeredViewComponent) {
64-
if ($registeredViewComponent->file !== $viewComponent) {
65-
continue;
66-
}
67-
68-
$viewComponent = $registeredViewComponent;
69-
70-
break;
71-
}
72-
} else {
73-
$viewComponent = $this->viewConfig->viewComponents[$viewComponent] ?? null;
63+
return array_find(
64+
array: $this->viewConfig->viewComponents,
65+
callback: fn ($registeredViewComponent) => $registeredViewComponent->file === $viewComponent,
66+
);
7467
}
7568

76-
return $viewComponent;
69+
return $this->viewConfig->viewComponents[$viewComponent] ?? null;
7770
}
7871

7972
private function resolveSlots(ViewComponent $viewComponent): ImmutableArray

0 commit comments

Comments
 (0)