Code Duplication    Length = 24-24 lines in 2 locations

src/voku/helper/SimpleHtmlDom.php 1 location

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

src/voku/helper/HtmlDomParser.php 1 location

@@ 446-469 (lines=24) @@
443
   *
444
   * @return SimpleHtmlDomNode|SimpleHtmlDomNode[]|SimpleHtmlDomNodeBlank
445
   */
446
  public function getElementsByTagName($name, $idx = null)
447
  {
448
    $nodesList = $this->document->getElementsByTagName($name);
449
450
    $elements = new SimpleHtmlDomNode();
451
452
    foreach ($nodesList as $node) {
453
      $elements[] = new SimpleHtmlDom($node);
454
    }
455
456
    if (null === $idx) {
457
      return $elements;
458
    } else {
459
      if ($idx < 0) {
460
        $idx = count($elements) + $idx;
461
      }
462
    }
463
464
    if (isset($elements[$idx])) {
465
      return $elements[$idx];
466
    } else {
467
      return new SimpleHtmlDomNodeBlank();
468
    }
469
  }
470
471
  /**
472
   * Find list of nodes with a CSS selector.