Code Duplication    Length = 14-15 lines in 2 locations

source/FluidXml/FluidContext.php 2 locations

@@ 207-220 (lines=14) @@
204
                }, $this);
205
        }
206
207
        public function prependSibling($sibling, ...$optionals)
208
        {
209
                return $this->handler->insertElement($this->nodes, $sibling, $optionals, function ($sibling, $element) {
210
                        if ($sibling->parentNode === null) {
211
                                // If the node doesn't have at least one parent node,
212
                                // the sibling creation fails. In this case we replace
213
                                // the sibling creation with the creation of a child node.
214
                                // Useful when dealing with a DOMDocument with a null
215
                                // documentElement property.
216
                                return $sibling->appendChild($element);
217
                        }
218
                        return $sibling->parentNode->insertBefore($element, $sibling);
219
                }, $this);
220
        }
221
222
        public function appendSibling($sibling, ...$optionals)
223
        {
@@ 222-236 (lines=15) @@
219
                }, $this);
220
        }
221
222
        public function appendSibling($sibling, ...$optionals)
223
        {
224
                return $this->handler->insertElement($this->nodes, $sibling, $optionals, function ($sibling, $element) {
225
                        if ($sibling->parentNode === null) {
226
                                // If the node doesn't have at least one parent node,
227
                                // the sibling creation fails. In this case we replace
228
                                // the sibling creation with the creation of a child node.
229
                                // Useful when dealing with a DOMDocument with a null
230
                                // documentElement property.
231
                                return $sibling->appendChild($element);
232
                        }
233
                        // If ->nextSibling is null, $element is simply appended as last sibling.
234
                        return $sibling->parentNode->insertBefore($element, $sibling->nextSibling);
235
                }, $this);
236
        }
237
238
        // setAttribute($name, $value)
239
        // setAttribute(['name' => 'value', ...])