- FormFieldBindingMergeStrategy::nullWinnerBehaviour() and isValidForScalarTargets() encode the per-strategy null-winner matrix (RFC Q7) and the collection-only restriction (RFC V1). - ResolvedBinding/BindingApplicationResult/BindingPassResult readonly DTOs for the binding pipeline. Construction-time validation for trust level. Apply-status derived from result aggregate. Note: the existing enum is named FormFieldBindingMergeStrategy (not MergeStrategy as the prompt sketched). Methods added to it directly. Refs: RFC-WS-6.md §3 (Q4, Q7), §4 (V1) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
43 lines
1.3 KiB
PHP
43 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\FormBuilder\Bindings;
|
|
|
|
use App\Enums\FormBuilder\BindingTargetType;
|
|
use App\Enums\FormBuilder\FormFieldBindingMergeStrategy;
|
|
use InvalidArgumentException;
|
|
|
|
/**
|
|
* RFC-WS-6 §3 (Q7) — output of `BindingConflictResolver`. One winning
|
|
* binding per `(target_entity, target_attribute)` group, ready for the
|
|
* applicator to write.
|
|
*/
|
|
final readonly class ResolvedBinding
|
|
{
|
|
public function __construct(
|
|
public string $sourceFormFieldId,
|
|
public string $bindingId,
|
|
public string $targetEntity,
|
|
public string $targetAttribute,
|
|
public BindingTargetType $targetType,
|
|
public FormFieldBindingMergeStrategy $mergeStrategy,
|
|
public int $trustLevel,
|
|
public bool $isIdentityKey,
|
|
public mixed $value,
|
|
public bool $valueIsExplicit,
|
|
) {
|
|
if ($trustLevel < 0 || $trustLevel > 100) {
|
|
throw new InvalidArgumentException(
|
|
"trustLevel must be in [0,100]; got {$trustLevel}",
|
|
);
|
|
}
|
|
if ($targetEntity === '') {
|
|
throw new InvalidArgumentException('targetEntity must not be empty');
|
|
}
|
|
if ($targetAttribute === '') {
|
|
throw new InvalidArgumentException('targetAttribute must not be empty');
|
|
}
|
|
}
|
|
}
|