Code Duplication    Length = 23-24 lines in 4 locations

src/voku/helper/UTF8.php 4 locations

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