<?php

namespace NoahVet\Reef\Domain\Security\Policy;

use NoahVet\Reef\Domain\Security\Model\Resource;
use NoahVet\Reef\Domain\Security\Model\ResourceGroup;

class PolicyResult
{
    public ?string $etag = null;

    protected string $policyName;

    protected Resource|ResourceGroup $subject;

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

    public function __construct(
        string $policyName,
        Resource|ResourceGroup $subject,
    ) {
        $this->policyName = $policyName;
        $this->subject = $subject;
    }

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

    public function getSubject(): Resource|ResourceGroup
    {
        return $this->subject;
    }

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

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