DeleteMapper
Marks the bindable as non-existing, effectively removing it from the bind flow and the output. It takes no arguments and performs no validation.
It is most often combined with Mappers::subProps() to clear a structured bindable before re-mapping only some of its children — delete() drops the whole bindable, then the following subProps() re-creates just the declared children.
For conditional removal, see the
deleteIffamily in DoIfMapper.
Example: dropping a prop from the output
$target = new DataMap();
Bind::attrs(['keep' => 'a', 'drop' => 'b'])->toAttrs($target)
->prop('keep')
->prop('drop', Mappers::delete())
->exec();
var_dump($target->toArray());
Output:
array(1) {
["keep"]=>
string(1) "a"
}
drop is removed; only keep is written.