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