## Summary - add the shared resolved-reference foundation with registry, resolvers, presenters, and badge semantics - refactor related context, assignment evidence, and policy-version assignment rendering toward label-first reference presentation - add Spec 132 artifacts and focused Pest coverage for reference resolution, degraded states, canonical linking, and tenant-context carryover ## Verification - `vendor/bin/sail bin pint --dirty --format agent` - focused Pest verification was marked complete in the task artifact ## Notes - this PR is opened from the current session branch - `specs/132-guid-context-resolver/tasks.md` reflects in-progress completion state for the implemented tasks Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #161
61 lines
1.6 KiB
PHP
61 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Support\References;
|
|
|
|
final readonly class ReferenceTechnicalDetail
|
|
{
|
|
public function __construct(
|
|
public ?string $displayId,
|
|
public string $fullId,
|
|
public ?string $sourceHint = null,
|
|
public bool $copyable = true,
|
|
public bool $defaultCollapsed = true,
|
|
) {}
|
|
|
|
public static function forIdentifier(
|
|
string $fullId,
|
|
?string $sourceHint = null,
|
|
bool $copyable = true,
|
|
bool $defaultCollapsed = true,
|
|
): self {
|
|
return new self(
|
|
displayId: self::displayId($fullId),
|
|
fullId: $fullId,
|
|
sourceHint: $sourceHint,
|
|
copyable: $copyable,
|
|
defaultCollapsed: $defaultCollapsed,
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @return array{displayId: ?string, fullId: string, sourceHint: ?string, copyable: bool, defaultCollapsed: bool}
|
|
*/
|
|
public function toArray(): array
|
|
{
|
|
return [
|
|
'displayId' => $this->displayId,
|
|
'fullId' => $this->fullId,
|
|
'sourceHint' => $this->sourceHint,
|
|
'copyable' => $this->copyable,
|
|
'defaultCollapsed' => $this->defaultCollapsed,
|
|
];
|
|
}
|
|
|
|
private static function displayId(string $fullId): ?string
|
|
{
|
|
$normalized = preg_replace('/[^a-zA-Z0-9]/', '', $fullId);
|
|
|
|
if (! is_string($normalized) || $normalized === '') {
|
|
return null;
|
|
}
|
|
|
|
if (mb_strlen($normalized) <= 8) {
|
|
return $normalized;
|
|
}
|
|
|
|
return '…'.mb_substr($normalized, -8);
|
|
}
|
|
}
|