<?php

declare(strict_types=1);

namespace App\Support\Baselines;

final class SubjectDescriptor
{
    /**
     * @param  non-empty-string  $policyType
     * @param  non-empty-string  $subjectKey
     * @param  'supported'|'limited'|'excluded'|'invalid_support_config'  $supportMode
     * @param  'policy'|'inventory'|'derived'|null  $sourceModelExpected
     */
    public function __construct(
        public readonly string $policyType,
        public readonly ?string $subjectExternalId,
        public readonly string $subjectKey,
        public readonly SubjectClass $subjectClass,
        public readonly ResolutionPath $resolutionPath,
        public readonly string $supportMode,
        public readonly ?string $sourceModelExpected,
    ) {}

    public function expectsPolicy(): bool
    {
        return $this->sourceModelExpected === 'policy';
    }

    public function expectsInventory(): bool
    {
        return $this->sourceModelExpected === 'inventory';
    }

    public function toArray(): array
    {
        return [
            'policy_type' => $this->policyType,
            'subject_external_id' => $this->subjectExternalId,
            'subject_key' => $this->subjectKey,
            'subject_class' => $this->subjectClass->value,
            'resolution_path' => $this->resolutionPath->value,
            'support_mode' => $this->supportMode,
            'source_model_expected' => $this->sourceModelExpected,
        ];
    }
}
