<?php

namespace NoahVet\Reef\Domain\Security\Model;

class ResourceGroupWithMembers extends ResourceGroup
{
    /**
     * @var \NoahVet\Reef\Domain\Security\Model\Resource[]
     */
    protected array $members = [];

    /**
     * @param string[] $members
     */
    public static function fromStringWithMembers(
        ResourceType|string $resourceType,
        mixed $groupId,
        array $members,
    ): static {
        $ret = new static(
            \is_string($resourceType) ? ResourceType::fromString($resourceType) : $resourceType,
            (string) $groupId,
        );

        $ret->members = \array_map(
            static fn (string $member) => Resource::fromString($resourceType, $member),
            $members,
        );

        return $ret;
    }

    /**
     * @return \NoahVet\Reef\Domain\Security\Model\Resource[]
     */
    public function getMembers(): array
    {
        return $this->members;
    }
}
