Code Duplication    Length = 24-24 lines in 2 locations

src/voku/helper/SimpleHtmlDom.php 1 location

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

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.