<?php

namespace NoahVet\Reef\Domain\Security\Policy;

use NoahVet\Reef\Domain\Security\Model\ResourceType;

class PolicyResult
{
    public ?string $etag = null;

    protected string $policyName;

    protected string $subject;

    protected ResourceType $resourceType;

    /**
     * @var list<PolicyResultGrant>
     */
    protected array $grants = [];

    public function __construct(
        string $policyName,
        string $subject,
        ResourceType $resourceType,
    ) {
        $this->policyName = $policyName;
        $this->subject = $subject;
        $this->resourceType = $resourceType;
    }

    public function getPolicyName(): string
    {
        return $this->policyName;
    }

    public function getSubject(): string
    {
        return $this->subject;
    }

    public function getResourceType(): ResourceType
    {
        return $this->resourceType;
    }

    public function addGrant(PolicyResultGrant $grant): void
    {
        $this->grants[] = $grant;
    }

    /**
     * @return list<PolicyResultGrant>
     */
    public function getGrants(): array
    {
        return $this->grants;
    }
}
