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

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