<?php

declare(strict_types=1);

namespace App\Support\References;

use Illuminate\Support\Str;

final class ReferenceTypeLabelCatalog
{
    /**
     * @var array<string, string>
     */
    private const LABELS = [
        ReferenceClass::Policy->value => 'Policy',
        ReferenceClass::PolicyVersion->value => 'Policy version',
        ReferenceClass::BaselineProfile->value => 'Baseline profile',
        ReferenceClass::BaselineSnapshot->value => 'Baseline snapshot',
        ReferenceClass::OperationRun->value => 'Operation',
        ReferenceClass::BackupSet->value => 'Backup set',
        ReferenceClass::RoleDefinition->value => 'Role definition',
        ReferenceClass::Principal->value => 'Principal',
        ReferenceClass::Group->value => 'Group',
        ReferenceClass::ServicePrincipal->value => 'Service principal',
        ReferenceClass::TenantExternalObject->value => 'External object',
        ReferenceClass::Unsupported->value => 'Reference',
    ];

    public function label(ReferenceClass|string $referenceClass): string
    {
        $value = $referenceClass instanceof ReferenceClass ? $referenceClass->value : $referenceClass;

        return self::LABELS[$value] ?? Str::headline(str_replace('_', ' ', $value));
    }
}
