$children * @param mixed $value */ public static function branch(array $children, Type $type = null, $value = null): Node { $shell = Shell::root($type ?? FakeType::permissive(), $value); $nodes = []; foreach ($children as $key => $child) { $childValue = $child['value'] ?? []; $node = Node::leaf($shell->child( $child['name'] ?? (string)$key, $child['type'] ?? FakeType::permissive(), $childValue, $child['attributes'] ?? new FakeAttributes(), ), $childValue); if (isset($child['message'])) { $node = $node->withMessage($child['message']); } $nodes[] = $node; } return Node::branch($shell, $value, $nodes); } /** * @param Throwable&Message $error */ public static function error(Throwable $error = null): Node { $shell = Shell::root(FakeType::permissive(), []); return Node::error($shell, $error ?? new FakeErrorMessage()); } }