<?php

declare(strict_types=1);

namespace App\Support\Governance;

final readonly class SubjectDescriptorNormalizationResult
{
    /**
     * @param  list<string>  $warnings
     */
    public function __construct(
        public PlatformSubjectDescriptor $descriptor,
        public string $sourceSurface,
        public bool $usedLegacyAlias = false,
        public array $warnings = [],
    ) {}

    /**
     * @return array{
     *     descriptor: array{
     *         domain_key: string,
     *         subject_class: string,
     *         subject_type_key: string,
     *         subject_type_label: string,
     *         platform_noun: string,
     *         display_label: string,
     *         legacy_policy_type: ?string,
     *         owner_layer: string
     *     },
     *     source_surface: string,
     *     used_legacy_alias: bool,
     *     warnings: list<string>
     * }
     */
    public function toArray(): array
    {
        return [
            'descriptor' => $this->descriptor->toArray(),
            'source_surface' => $this->sourceSurface,
            'used_legacy_alias' => $this->usedLegacyAlias,
            'warnings' => $this->warnings,
        ];
    }
}