$services Array of service class names */ public function __construct( public readonly array $services ) {} /** * Filter services by group (social, AI, media, miscellaneous). * * Requires Core\Mod\Social module to be installed for ServiceGroup enum. * * @param object|array|null $group Service group(s) to filter by (ServiceGroup enum) * @return static New collection containing only services in the specified group(s) */ public function group(object|array|null $group = null): static { return new static( array_values( array_filter($this->services, function ($serviceClass) use ($group) { return in_array($serviceClass::group(), Arr::wrap($group)); }) ) ); } /** * Get the array of service class names. * * @return array */ public function getClasses(): array { return $this->services; } /** * Get the array of service names. * * @return array */ public function getNames(): array { return array_map(fn ($service) => $service::name(), $this->services); } /** * Get the collection as an array of service metadata. * * Returns an array where each element contains: * - name: The service name (e.g., 'facebook', 'twitter') * - group: The service group enum (social, AI, media, miscellaneous) * - form: The form configuration array for the service * * @return array */ public function getCollection(): array { return array_map(function ($serviceClass) { return [ 'name' => $serviceClass::name(), 'group' => $serviceClass::group(), 'form' => $serviceClass::form(), ]; }, $this->services); } /** * Convert the collection to an array. * * @return array */ public function __array(): array { return $this->services; } }