Skip to content

Commit 6dc9619

Browse files
committed
Refactor filterPrimitives method to improve class string handling and merging logic
Signed-off-by: Pushpak Chhajed <[email protected]>
1 parent a76bfc5 commit 6dc9619

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/Mcp/Boost.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,20 @@ private function discoverThirdPartyPrimitives(string $primitiveType): array
165165
*/
166166
private function filterPrimitives(array $availablePrimitives, string $type): array
167167
{
168-
return collect($availablePrimitives)
168+
$collection = collect($availablePrimitives);
169+
170+
$classStrings = $collection->filter(fn ($item): bool => is_string($item));
171+
$instances = $collection->reject(fn ($item): bool => is_string($item));
172+
173+
$filteredClassStrings = $classStrings
169174
->diff(config("boost.mcp.{$type}.exclude", []))
170175
->merge(
171176
collect(config("boost.mcp.{$type}.include", []))
172177
->filter(fn (string $class): bool => class_exists($class))
173-
)
178+
);
179+
180+
return $filteredClassStrings
181+
->merge($instances)
174182
->values()
175183
->all();
176184
}

0 commit comments

Comments
 (0)