Code Duplication    Length = 23-24 lines in 4 locations

src/voku/helper/UTF8.php 4 locations

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