3 declare(strict_types=1);
5 namespace CuyZ\Valinor\Mapper\Tree\Builder;
7 use CuyZ\Valinor\Mapper\Tree\Shell;
10 final class CasterProxyNodeBuilder implements NodeBuilder
12 public function __construct(private NodeBuilder $delegate) {}
14 public function build(Shell $shell, RootNodeBuilder $rootBuilder): TreeNode
16 if ($shell->hasValue()) {
17 $value = $shell->value();
19 if ($shell->type()->accepts($value)) {
20 return TreeNode::leaf($shell, $value);
24 return $this->delegate->build($shell, $rootBuilder);