Code Duplication    Length = 23-24 lines in 4 locations

src/voku/helper/UTF8.php 4 locations

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