Code Duplication    Length = 23-24 lines in 4 locations

src/voku/helper/UTF8.php 4 locations

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