Conditions | 3 |
Paths | 3 |
Total Lines | 19 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
48 | public function replaceNode(Node $oldNode, ?Node $newNode = null): void |
||
49 | { |
||
50 | $index = \array_search($oldNode, $this->nodes, true); |
||
51 | |||
52 | if ($index === false) { |
||
53 | return; |
||
54 | } |
||
55 | |||
56 | $replacement = []; |
||
57 | |||
58 | if ($newNode !== null) { |
||
59 | $oldNode->setDocument(); |
||
60 | $newNode->setDocument($this); |
||
61 | $replacement[] = $newNode; |
||
62 | } |
||
63 | |||
64 | \array_splice($this->nodes, (int) $index, 1, $replacement); |
||
65 | |||
66 | $this->nodes = \array_values($this->nodes); |
||
67 | } |
||
69 |