Code Duplication    Length = 15-16 lines in 2 locations

code/api/thirdparty/simple_html_dom.php 2 locations

@@ 280-295 (lines=16) @@
277
    }
278
279
    // returns the next sibling of node
280
    public function next_sibling()
281
    {
282
        if ($this->parent===null) {
283
            return null;
284
        }
285
286
        $idx = 0;
287
        $count = count($this->parent->children);
288
        while ($idx<$count && $this!==$this->parent->children[$idx]) {
289
            ++$idx;
290
        }
291
        if (++$idx>=$count) {
292
            return null;
293
        }
294
        return $this->parent->children[$idx];
295
    }
296
297
    // returns the previous sibling of node
298
    public function prev_sibling()
@@ 298-312 (lines=15) @@
295
    }
296
297
    // returns the previous sibling of node
298
    public function prev_sibling()
299
    {
300
        if ($this->parent===null) {
301
            return null;
302
        }
303
        $idx = 0;
304
        $count = count($this->parent->children);
305
        while ($idx<$count && $this!==$this->parent->children[$idx]) {
306
            ++$idx;
307
        }
308
        if (--$idx<0) {
309
            return null;
310
        }
311
        return $this->parent->children[$idx];
312
    }
313
314
    // function to locate a specific ancestor tag in the path to the root.
315
    public function find_ancestor_tag($tag)