Code Duplication    Length = 23-24 lines in 4 locations

src/voku/helper/UTF8.php 4 locations

@@ 6670-6693 (lines=24) @@
6667
   *
6668
   * @return string <p>Return the sub-string.</p>
6669
   */
6670
  public static function substr_ileft($haystack, $needle)
6671
  {
6672
    // init
6673
    $haystack = (string)$haystack;
6674
    $needle = (string)$needle;
6675
6676
    if (!isset($haystack[0])) {
6677
      return '';
6678
    }
6679
6680
    if (!isset($needle[0])) {
6681
      return $haystack;
6682
    }
6683
6684
    if (self::str_istarts_with($haystack, $needle) === true) {
6685
      $haystackTmp = self::substr($haystack, self::strlen($needle));
6686
      if ($haystackTmp === false) {
6687
        $haystackTmp = '';
6688
      }
6689
      $haystack = (string)$haystackTmp;
6690
    }
6691
6692
    return $haystack;
6693
  }
6694
6695
  /**
6696
   * Removes an suffix ($needle) from end of the string ($haystack), case insensitive.
@@ 6703-6726 (lines=24) @@
6700
   *
6701
   * @return string <p>Return the sub-string.</p>
6702
   */
6703
  public static function substr_iright($haystack, $needle)
6704
  {
6705
    // init
6706
    $haystack = (string)$haystack;
6707
    $needle = (string)$needle;
6708
6709
    if (!isset($haystack[0])) {
6710
      return '';
6711
    }
6712
6713
    if (!isset($needle[0])) {
6714
      return $haystack;
6715
    }
6716
6717
    if (self::str_iends_with($haystack, $needle) === true) {
6718
      $haystackTmp = self::substr($haystack, 0, self::strlen($haystack) - self::strlen($needle));
6719
      if ($haystackTmp === false) {
6720
        $haystackTmp = '';
6721
      }
6722
      $haystack = (string)$haystackTmp;
6723
    }
6724
6725
    return $haystack;
6726
  }
6727
6728
  /**
6729
   * Removes an prefix ($needle) from start of the string ($haystack).
@@ 6736-6759 (lines=24) @@
6733
   *
6734
   * @return string <p>Return the sub-string.</p>
6735
   */
6736
  public static function substr_left($haystack, $needle)
6737
  {
6738
    // init
6739
    $haystack = (string)$haystack;
6740
    $needle = (string)$needle;
6741
6742
    if (!isset($haystack[0])) {
6743
      return '';
6744
    }
6745
6746
    if (!isset($needle[0])) {
6747
      return $haystack;
6748
    }
6749
6750
    if (self::str_starts_with($haystack, $needle) === true) {
6751
      $haystackTmp = self::substr($haystack, self::strlen($needle));
6752
      if ($haystackTmp === false) {
6753
        $haystackTmp = '';
6754
      }
6755
      $haystack = (string)$haystackTmp;
6756
    }
6757
6758
    return $haystack;
6759
  }
6760
6761
  /**
6762
   * Replace text within a portion of a string.
@@ 6875-6897 (lines=23) @@
6872
   *
6873
   * @return string <p>Return the sub-string.</p>
6874
   */
6875
  public static function substr_right($haystack, $needle)
6876
  {
6877
    $haystack = (string)$haystack;
6878
    $needle = (string)$needle;
6879
6880
    if (!isset($haystack[0])) {
6881
      return '';
6882
    }
6883
6884
    if (!isset($needle[0])) {
6885
      return $haystack;
6886
    }
6887
6888
    if (self::str_ends_with($haystack, $needle) === true) {
6889
      $haystackTmp = self::substr($haystack, 0, self::strlen($haystack) - self::strlen($needle));
6890
      if ($haystackTmp === false) {
6891
        $haystackTmp = '';
6892
      }
6893
      $haystack = (string)$haystackTmp;
6894
    }
6895
6896
    return $haystack;
6897
  }
6898
6899
  /**
6900
   * Returns a case swapped version of the string.