Code Duplication    Length = 24-24 lines in 2 locations

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.

src/voku/helper/HtmlDomParser.php 1 location

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