Code Duplication    Length = 24-24 lines in 2 locations

src/voku/helper/HtmlDomParser.php 1 location

@@ 376-399 (lines=24) @@
373
   *
374
   * @return SimpleHtmlDomNode|SimpleHtmlDomNode[]|SimpleHtmlDomNodeBlank
375
   */
376
  public function getElementsByTagName($name, $idx = null)
377
  {
378
    $nodesList = $this->document->getElementsByTagName($name);
379
380
    $elements = new SimpleHtmlDomNode();
381
382
    foreach ($nodesList as $node) {
383
      $elements[] = new SimpleHtmlDom($node);
384
    }
385
386
    if (null === $idx) {
387
      return $elements;
388
    } else {
389
      if ($idx < 0) {
390
        $idx = count($elements) + $idx;
391
      }
392
    }
393
394
    if (isset($elements[$idx])) {
395
      return $elements[$idx];
396
    } else {
397
      return new SimpleHtmlDomNodeBlank();
398
    }
399
  }
400
401
  /**
402
   * Find list of nodes with a CSS selector.

src/voku/helper/SimpleHtmlDom.php 1 location

@@ 299-322 (lines=24) @@
296
   *
297
   * @return SimpleHtmlDomNode|SimpleHtmlDomNode[]|SimpleHtmlDomNodeBlank
298
   */
299
  public function getElementsByTagName($name, $idx = null)
300
  {
301
    $nodesList = $this->node->getElementsByTagName($name);
302
303
    $elements = new SimpleHtmlDomNode();
304
305
    foreach ($nodesList as $node) {
306
      $elements[] = new self($node);
307
    }
308
309
    if (null === $idx) {
310
      return $elements;
311
    } else {
312
      if ($idx < 0) {
313
        $idx = count($elements) + $idx;
314
      }
315
    }
316
317
    if (isset($elements[$idx])) {
318
      return $elements[$idx];
319
    } else {
320
      return new SimpleHtmlDomNodeBlank();
321
    }
322
  }
323
324
  /**
325
   * Create a new "HtmlDomParser"-object from the current context.