<?php

namespace NoahVet\Reef\Security\IAM\Mapper;

use NoahVet\Reef\Domain\Security\Model\Resource;
use NoahVet\Reef\Security\User\ReefOAuthUser;

class ReefOAuthUserMapper implements InternalResourceMapperInterface
{
    #[\Override]
    public function canMap(mixed $entity): bool
    {
        return $entity instanceof ReefOAuthUser;
    }

    #[\Override]
    public function mapResource(mixed $entity): Resource
    {
        \assert($entity instanceof ReefOAuthUser);

        return Resource::fromString('reef:iam:principal', $entity->getUserIdentifier());
    }
}
