Skip to content

Commit 5f50b78

Browse files
committed
Refactor
Signed-off-by: Pushpak Chhajed <[email protected]>
1 parent 6dc9619 commit 5f50b78

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/Mcp/Boost.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -165,20 +165,20 @@ private function discoverThirdPartyPrimitives(string $primitiveType): array
165165
*/
166166
private function filterPrimitives(array $availablePrimitives, string $type): array
167167
{
168-
$collection = collect($availablePrimitives);
168+
$excludeList = config("boost.mcp.{$type}.exclude", []);
169+
$includeList = config("boost.mcp.{$type}.include", []);
169170

170-
$classStrings = $collection->filter(fn ($item): bool => is_string($item));
171-
$instances = $collection->reject(fn ($item): bool => is_string($item));
171+
$filtered = collect($availablePrimitives)->reject(function (string|object $item) use ($excludeList): bool {
172+
$className = is_string($item) ? $item : $item::class;
172173

173-
$filteredClassStrings = $classStrings
174-
->diff(config("boost.mcp.{$type}.exclude", []))
175-
->merge(
176-
collect(config("boost.mcp.{$type}.include", []))
177-
->filter(fn (string $class): bool => class_exists($class))
178-
);
174+
return in_array($className, $excludeList, true);
175+
});
179176

180-
return $filteredClassStrings
181-
->merge($instances)
177+
$explicitlyIncluded = collect($includeList)
178+
->filter(fn (string $class): bool => class_exists($class));
179+
180+
return $filtered
181+
->merge($explicitlyIncluded)
182182
->values()
183183
->all();
184184
}

0 commit comments

Comments
 (0)