Code Duplication    Length = 24-24 lines in 2 locations

src/voku/helper/HtmlDomParser.php 1 location

@@ 461-484 (lines=24) @@
458
   *
459
   * @return SimpleHtmlDomNode|SimpleHtmlDomNode[]|SimpleHtmlDomNodeBlank
460
   */
461
  public function getElementsByTagName($name, $idx = null)
462
  {
463
    $nodesList = $this->document->getElementsByTagName($name);
464
465
    $elements = new SimpleHtmlDomNode();
466
467
    foreach ($nodesList as $node) {
468
      $elements[] = new SimpleHtmlDom($node);
469
    }
470
471
    if (null === $idx) {
472
      return $elements;
473
    } else {
474
      if ($idx < 0) {
475
        $idx = count($elements) + $idx;
476
      }
477
    }
478
479
    if (isset($elements[$idx])) {
480
      return $elements[$idx];
481
    } else {
482
      return new SimpleHtmlDomNodeBlank();
483
    }
484
  }
485
486
  /**
487
   * Find list of nodes with a CSS selector.

src/voku/helper/SimpleHtmlDom.php 1 location

@@ 320-343 (lines=24) @@
317
   *
318
   * @return SimpleHtmlDomNode|SimpleHtmlDomNode[]|SimpleHtmlDomNodeBlank
319
   */
320
  public function getElementsByTagName($name, $idx = null)
321
  {
322
    $nodesList = $this->node->getElementsByTagName($name);
323
324
    $elements = new SimpleHtmlDomNode();
325
326
    foreach ($nodesList as $node) {
327
      $elements[] = new self($node);
328
    }
329
330
    if (null === $idx) {
331
      return $elements;
332
    } else {
333
      if ($idx < 0) {
334
        $idx = count($elements) + $idx;
335
      }
336
    }
337
338
    if (isset($elements[$idx])) {
339
      return $elements[$idx];
340
    } else {
341
      return new SimpleHtmlDomNodeBlank();
342
    }
343
  }
344
345
  /**
346
   * Create a new "HtmlDomParser"-object from the current context.