Code Duplication    Length = 23-24 lines in 4 locations

includes/libraries/protect/AntiXSS/UTF8.php 4 locations

@@ 6537-6560 (lines=24) @@
6534
   *
6535
   * @return string <p>Return the sub-string.</p>
6536
   */
6537
  public static function substr_ileft($haystack, $needle)
6538
  {
6539
    // init
6540
    $haystack = (string)$haystack;
6541
    $needle = (string)$needle;
6542
6543
    if (!isset($haystack[0])) {
6544
      return '';
6545
    }
6546
6547
    if (!isset($needle[0])) {
6548
      return $haystack;
6549
    }
6550
6551
    if (self::str_istarts_with($haystack, $needle) === true) {
6552
      $haystackTmp = self::substr($haystack, self::strlen($needle));
6553
      if ($haystackTmp === false) {
6554
        $haystackTmp = '';
6555
      }
6556
      $haystack = (string)$haystackTmp;
6557
    }
6558
6559
    return $haystack;
6560
  }
6561
6562
  /**
6563
   * Removes an suffix ($needle) from end of the string ($haystack), case insensitive.
@@ 6570-6593 (lines=24) @@
6567
   *
6568
   * @return string <p>Return the sub-string.</p>
6569
   */
6570
  public static function substr_iright($haystack, $needle)
6571
  {
6572
    // init
6573
    $haystack = (string)$haystack;
6574
    $needle = (string)$needle;
6575
6576
    if (!isset($haystack[0])) {
6577
      return '';
6578
    }
6579
6580
    if (!isset($needle[0])) {
6581
      return $haystack;
6582
    }
6583
6584
    if (self::str_iends_with($haystack, $needle) === true) {
6585
      $haystackTmp = self::substr($haystack, 0, self::strlen($haystack) - self::strlen($needle));
6586
      if ($haystackTmp === false) {
6587
        $haystackTmp = '';
6588
      }
6589
      $haystack = (string)$haystackTmp;
6590
    }
6591
6592
    return $haystack;
6593
  }
6594
6595
  /**
6596
   * Removes an prefix ($needle) from start of the string ($haystack).
@@ 6603-6626 (lines=24) @@
6600
   *
6601
   * @return string <p>Return the sub-string.</p>
6602
   */
6603
  public static function substr_left($haystack, $needle)
6604
  {
6605
    // init
6606
    $haystack = (string)$haystack;
6607
    $needle = (string)$needle;
6608
6609
    if (!isset($haystack[0])) {
6610
      return '';
6611
    }
6612
6613
    if (!isset($needle[0])) {
6614
      return $haystack;
6615
    }
6616
6617
    if (self::str_starts_with($haystack, $needle) === true) {
6618
      $haystackTmp = self::substr($haystack, self::strlen($needle));
6619
      if ($haystackTmp === false) {
6620
        $haystackTmp = '';
6621
      }
6622
      $haystack = (string)$haystackTmp;
6623
    }
6624
6625
    return $haystack;
6626
  }
6627
6628
  /**
6629
   * Replace text within a portion of a string.
@@ 6733-6755 (lines=23) @@
6730
   *
6731
   * @return string <p>Return the sub-string.</p>
6732
   */
6733
  public static function substr_right($haystack, $needle)
6734
  {
6735
    $haystack = (string)$haystack;
6736
    $needle = (string)$needle;
6737
6738
    if (!isset($haystack[0])) {
6739
      return '';
6740
    }
6741
6742
    if (!isset($needle[0])) {
6743
      return $haystack;
6744
    }
6745
6746
    if (self::str_ends_with($haystack, $needle) === true) {
6747
      $haystackTmp = self::substr($haystack, 0, self::strlen($haystack) - self::strlen($needle));
6748
      if ($haystackTmp === false) {
6749
        $haystackTmp = '';
6750
      }
6751
      $haystack = (string)$haystackTmp;
6752
    }
6753
6754
    return $haystack;
6755
  }
6756
6757
  /**
6758
   * Returns a case swapped version of the string.