<?php

declare(strict_types=1);

namespace App\Support\Artifacts;

use Illuminate\Support\Str;

final class ArtifactSourceTaxonomy
{
    public const string SOURCE_FAMILY_FINDING = 'finding';

    public const string SOURCE_FAMILY_STORED_REPORT = 'stored_report';

    public const string SOURCE_FAMILY_EVIDENCE_SNAPSHOT = 'evidence_snapshot';

    public const string SOURCE_FAMILY_INVENTORY = 'inventory';

    public const string SOURCE_FAMILY_OPERATION_RUN = 'operation_run';

    public const string SOURCE_KIND_MODEL_SUMMARY = 'model_summary';

    public const string SOURCE_KIND_STORED_REPORT = 'stored_report';

    public const string SOURCE_KIND_OPERATION_ROLLUP = 'operation_rollup';

    public const string SOURCE_KIND_INVENTORY_PROJECTION = 'inventory_projection';

    public const string SOURCE_TARGET_MANAGED_ENVIRONMENT = 'managed_environment';

    public const string SOURCE_TARGET_GOVERNED_SUBJECT = 'governed_subject';

    public const string SOURCE_TARGET_PROVIDER_CONNECTION = 'provider_connection';

    public const string SOURCE_TARGET_OPERATION_RUN = 'operation_run';

    /**
     * @return list<string>
     */
    public static function sourceFamilies(): array
    {
        return [
            self::SOURCE_FAMILY_FINDING,
            self::SOURCE_FAMILY_STORED_REPORT,
            self::SOURCE_FAMILY_EVIDENCE_SNAPSHOT,
            self::SOURCE_FAMILY_INVENTORY,
            self::SOURCE_FAMILY_OPERATION_RUN,
        ];
    }

    /**
     * @return list<string>
     */
    public static function sourceKinds(): array
    {
        return [
            self::SOURCE_KIND_MODEL_SUMMARY,
            self::SOURCE_KIND_STORED_REPORT,
            self::SOURCE_KIND_OPERATION_ROLLUP,
            self::SOURCE_KIND_INVENTORY_PROJECTION,
        ];
    }

    /**
     * @return list<string>
     */
    public static function sourceTargetKinds(): array
    {
        return [
            self::SOURCE_TARGET_MANAGED_ENVIRONMENT,
            self::SOURCE_TARGET_GOVERNED_SUBJECT,
            self::SOURCE_TARGET_PROVIDER_CONNECTION,
            self::SOURCE_TARGET_OPERATION_RUN,
        ];
    }

    public static function hasDetectorCatalog(): bool
    {
        return false;
    }

    public static function isSourceFamily(string $value): bool
    {
        return in_array($value, self::sourceFamilies(), true);
    }

    public static function isSourceKind(string $value): bool
    {
        return in_array($value, self::sourceKinds(), true);
    }

    public static function isSourceTargetKind(string $value): bool
    {
        return in_array($value, self::sourceTargetKinds(), true);
    }

    public static function label(?string $value): string
    {
        return filled($value) ? Str::headline((string) $value) : 'Unknown';
    }
}
