TenantAtlas/apps/platform/app/Support/Baselines/Compare/CompareSubjectIdentity.php
2026-04-13 23:09:11 +02:00

42 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Support\Baselines\Compare;
use InvalidArgumentException;
final class CompareSubjectIdentity
{
public function __construct(
public readonly string $domainKey,
public readonly string $subjectClass,
public readonly string $subjectTypeKey,
public readonly ?string $externalSubjectId,
public readonly string $subjectKey,
) {
if (trim($this->domainKey) === '' || trim($this->subjectClass) === '' || trim($this->subjectTypeKey) === '' || trim($this->subjectKey) === '') {
throw new InvalidArgumentException('Compare subject identities require non-empty domain, subject class, subject type key, and subject key values.');
}
}
/**
* @return array{
* domain_key: string,
* subject_class: string,
* subject_type_key: string,
* external_subject_id: ?string,
* subject_key: string
* }
*/
public function toArray(): array
{
return [
'domain_key' => $this->domainKey,
'subject_class' => $this->subjectClass,
'subject_type_key' => $this->subjectTypeKey,
'external_subject_id' => $this->externalSubjectId,
'subject_key' => $this->subjectKey,
];
}
}