Code Duplication    Length = 24-24 lines in 2 locations

src/voku/helper/HtmlDomParser.php 1 location

@@ 393-416 (lines=24) @@
390
   *
391
   * @return SimpleHtmlDomNode|SimpleHtmlDomNode[]|SimpleHtmlDomNodeBlank
392
   */
393
  public function getElementsByTagName($name, $idx = null)
394
  {
395
    $nodesList = $this->document->getElementsByTagName($name);
396
397
    $elements = new SimpleHtmlDomNode();
398
399
    foreach ($nodesList as $node) {
400
      $elements[] = new SimpleHtmlDom($node);
401
    }
402
403
    if (null === $idx) {
404
      return $elements;
405
    } else {
406
      if ($idx < 0) {
407
        $idx = count($elements) + $idx;
408
      }
409
    }
410
411
    if (isset($elements[$idx])) {
412
      return $elements[$idx];
413
    } else {
414
      return new SimpleHtmlDomNodeBlank();
415
    }
416
  }
417
418
  /**
419
   * Find list of nodes with a CSS selector.

src/voku/helper/SimpleHtmlDom.php 1 location

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