FromBindDataClosureMapper
Builds a sub-mapper from a bindable's own array value. The bindable's value (which must be an array) is wrapped in a BindData and passed to the closure; the closure returns a Mapper, which is then run against that single bindable.
This lets you choose a sub-mapping plan based on the data itself — e.g. a dynamic subProps() plan that depends on which keys are present.
Contrast with
Mappers::valueAsBindDataClosure()(see ValueAsBindDataClosureMapper), which transforms the array value directly. Here the closure returns a mapper to apply. A non-array value throwsBindMismatchException.
Example: building a subProps plan from the value
$target = new DataMap();
Bind::attrs(['holeradio' => 'foo', 'sub' => ['huii' => 'bar']])->toAttrs($target)
->prop('sub', Mappers::fromBindDataClosure(function (BindData $bindData) {
return Mappers::subProps()->prop('huii', Mappers::value(fn ($v) => $v . '2'));
}))
->exec();
var_dump($target->req('sub/huii'));
Output:
string(4) "bar2"
The closure inspects sub's array value via BindData and returns a subProps mapper that transforms huii.