db2de428b2dd2689b8ccb0807e42f791378ef4b7
[GitHub/WoltLab/WCF.git] /
1 <?php
2
3 declare(strict_types=1);
4
5 namespace CuyZ\Valinor\Mapper\Tree\Builder;
6
7 use CuyZ\Valinor\Mapper\Tree\Shell;
8
9 /** @internal */
10 final class CasterProxyNodeBuilder implements NodeBuilder
11 {
12 public function __construct(private NodeBuilder $delegate) {}
13
14 public function build(Shell $shell, RootNodeBuilder $rootBuilder): TreeNode
15 {
16 if ($shell->hasValue()) {
17 $value = $shell->value();
18
19 if ($shell->type()->accepts($value)) {
20 return TreeNode::leaf($shell, $value);
21 }
22 }
23
24 return $this->delegate->build($shell, $rootBuilder);
25 }
26 }