<?php

declare(strict_types=1);

namespace App\Support\References;

final readonly class ReferenceDescriptor
{
    /**
     * @param  array<string, mixed>  $context
     */
    public function __construct(
        public ReferenceClass $referenceClass,
        public string $rawIdentifier,
        public ?int $workspaceId = null,
        public ?int $tenantId = null,
        public ?string $sourceType = null,
        public ?string $sourceSurface = null,
        public ?string $fallbackLabel = null,
        public ?int $linkedModelId = null,
        public ?string $linkedModelType = null,
        public array $context = [],
    ) {}

    public function contextValue(string $key, mixed $default = null): mixed
    {
        return data_get($this->context, $key, $default);
    }
}
