Code Duplication    Length = 14-15 lines in 2 locations

source/FluidXml/FluidContext.php 2 locations

@@ 220-233 (lines=14) @@
217
                }, $this);
218
        }
219
220
        public function prependSibling($sibling, ...$optionals)
221
        {
222
                return $this->handler->insertElement($this->nodes, $sibling, $optionals, function ($sibling, $element) {
223
                        if ($sibling->parentNode === null) {
224
                                // If the node doesn't have at least one parent node,
225
                                // the sibling creation fails. In this case we replace
226
                                // the sibling creation with the creation of a child node.
227
                                // Useful when dealing with a DOMDocument with a null
228
                                // documentElement property.
229
                                return $sibling->appendChild($element);
230
                        }
231
                        return $sibling->parentNode->insertBefore($element, $sibling);
232
                }, $this);
233
        }
234
235
        public function appendSibling($sibling, ...$optionals)
236
        {
@@ 235-249 (lines=15) @@
232
                }, $this);
233
        }
234
235
        public function appendSibling($sibling, ...$optionals)
236
        {
237
                return $this->handler->insertElement($this->nodes, $sibling, $optionals, function ($sibling, $element) {
238
                        if ($sibling->parentNode === null) {
239
                                // If the node doesn't have at least one parent node,
240
                                // the sibling creation fails. In this case we replace
241
                                // the sibling creation with the creation of a child node.
242
                                // Useful when dealing with a DOMDocument with a null
243
                                // documentElement property.
244
                                return $sibling->appendChild($element);
245
                        }
246
                        // If ->nextSibling is null, $element is simply appended as last sibling.
247
                        return $sibling->parentNode->insertBefore($element, $sibling->nextSibling);
248
                }, $this);
249
        }
250
251
        // setAttribute($name, $value)
252
        // setAttribute(['name' => 'value', ...])