Code Duplication    Length = 23-24 lines in 4 locations

src/voku/helper/UTF8.php 4 locations

@@ 6681-6704 (lines=24) @@
6678
   *
6679
   * @return string <p>Return the sub-string.</p>
6680
   */
6681
  public static function substr_ileft($haystack, $needle)
6682
  {
6683
    // init
6684
    $haystack = (string)$haystack;
6685
    $needle = (string)$needle;
6686
6687
    if (!isset($haystack[0])) {
6688
      return '';
6689
    }
6690
6691
    if (!isset($needle[0])) {
6692
      return $haystack;
6693
    }
6694
6695
    if (self::str_istarts_with($haystack, $needle) === true) {
6696
      $haystackTmp = self::substr($haystack, self::strlen($needle));
6697
      if ($haystackTmp === false) {
6698
        $haystackTmp = '';
6699
      }
6700
      $haystack = (string)$haystackTmp;
6701
    }
6702
6703
    return $haystack;
6704
  }
6705
6706
  /**
6707
   * Removes an suffix ($needle) from end of the string ($haystack), case insensitive.
@@ 6714-6737 (lines=24) @@
6711
   *
6712
   * @return string <p>Return the sub-string.</p>
6713
   */
6714
  public static function substr_iright($haystack, $needle)
6715
  {
6716
    // init
6717
    $haystack = (string)$haystack;
6718
    $needle = (string)$needle;
6719
6720
    if (!isset($haystack[0])) {
6721
      return '';
6722
    }
6723
6724
    if (!isset($needle[0])) {
6725
      return $haystack;
6726
    }
6727
6728
    if (self::str_iends_with($haystack, $needle) === true) {
6729
      $haystackTmp = self::substr($haystack, 0, self::strlen($haystack) - self::strlen($needle));
6730
      if ($haystackTmp === false) {
6731
        $haystackTmp = '';
6732
      }
6733
      $haystack = (string)$haystackTmp;
6734
    }
6735
6736
    return $haystack;
6737
  }
6738
6739
  /**
6740
   * Removes an prefix ($needle) from start of the string ($haystack).
@@ 6747-6770 (lines=24) @@
6744
   *
6745
   * @return string <p>Return the sub-string.</p>
6746
   */
6747
  public static function substr_left($haystack, $needle)
6748
  {
6749
    // init
6750
    $haystack = (string)$haystack;
6751
    $needle = (string)$needle;
6752
6753
    if (!isset($haystack[0])) {
6754
      return '';
6755
    }
6756
6757
    if (!isset($needle[0])) {
6758
      return $haystack;
6759
    }
6760
6761
    if (self::str_starts_with($haystack, $needle) === true) {
6762
      $haystackTmp = self::substr($haystack, self::strlen($needle));
6763
      if ($haystackTmp === false) {
6764
        $haystackTmp = '';
6765
      }
6766
      $haystack = (string)$haystackTmp;
6767
    }
6768
6769
    return $haystack;
6770
  }
6771
6772
  /**
6773
   * Replace text within a portion of a string.
@@ 6882-6904 (lines=23) @@
6879
   *
6880
   * @return string <p>Return the sub-string.</p>
6881
   */
6882
  public static function substr_right($haystack, $needle)
6883
  {
6884
    $haystack = (string)$haystack;
6885
    $needle = (string)$needle;
6886
6887
    if (!isset($haystack[0])) {
6888
      return '';
6889
    }
6890
6891
    if (!isset($needle[0])) {
6892
      return $haystack;
6893
    }
6894
6895
    if (self::str_ends_with($haystack, $needle) === true) {
6896
      $haystackTmp = self::substr($haystack, 0, self::strlen($haystack) - self::strlen($needle));
6897
      if ($haystackTmp === false) {
6898
        $haystackTmp = '';
6899
      }
6900
      $haystack = (string)$haystackTmp;
6901
    }
6902
6903
    return $haystack;
6904
  }
6905
6906
  /**
6907
   * Returns a case swapped version of the string.