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

@@ 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.