<?php

namespace NoahVet\Reef\Domain\Security\Principal;

class Principal implements PrincipalInterface
{
    protected string $id;

    public function __construct(string $id)
    {
        if (!\preg_match('{^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$}Di', $id)) {
            throw new \LogicException("The principal id `$id` should be a valid uuid.");
        }
        $this->id = $id;
    }

    #[\Override]
    public function getId(): string
    {
        return $this->id;
    }
}
