Code Duplication    Length = 23-24 lines in 4 locations

src/voku/helper/UTF8.php 4 locations

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