Code Duplication    Length = 20-20 lines in 4 locations

src/voku/helper/UTF8.php 4 locations

@@ 6862-6881 (lines=20) @@
6859
   *
6860
   * @return string <p>Return the sub-string.</p>
6861
   */
6862
  public static function substr_ileft(string $haystack, string $needle): string
6863
  {
6864
    if (!isset($haystack[0])) {
6865
      return '';
6866
    }
6867
6868
    if (!isset($needle[0])) {
6869
      return $haystack;
6870
    }
6871
6872
    if (self::str_istarts_with($haystack, $needle) === true) {
6873
      $haystackTmp = self::substr($haystack, self::strlen($needle));
6874
      if ($haystackTmp === false) {
6875
        $haystackTmp = '';
6876
      }
6877
      $haystack = (string)$haystackTmp;
6878
    }
6879
6880
    return $haystack;
6881
  }
6882
6883
  /**
6884
   * Removes an suffix ($needle) from end of the string ($haystack), case insensitive.
@@ 6891-6910 (lines=20) @@
6888
   *
6889
   * @return string <p>Return the sub-string.</p>
6890
   */
6891
  public static function substr_iright(string $haystack, string $needle): string
6892
  {
6893
    if (!isset($haystack[0])) {
6894
      return '';
6895
    }
6896
6897
    if (!isset($needle[0])) {
6898
      return $haystack;
6899
    }
6900
6901
    if (self::str_iends_with($haystack, $needle) === true) {
6902
      $haystackTmp = self::substr($haystack, 0, self::strlen($haystack) - self::strlen($needle));
6903
      if ($haystackTmp === false) {
6904
        $haystackTmp = '';
6905
      }
6906
      $haystack = (string)$haystackTmp;
6907
    }
6908
6909
    return $haystack;
6910
  }
6911
6912
  /**
6913
   * Removes an prefix ($needle) from start of the string ($haystack).
@@ 6920-6939 (lines=20) @@
6917
   *
6918
   * @return string <p>Return the sub-string.</p>
6919
   */
6920
  public static function substr_left(string $haystack, string $needle): string
6921
  {
6922
    if (!isset($haystack[0])) {
6923
      return '';
6924
    }
6925
6926
    if (!isset($needle[0])) {
6927
      return $haystack;
6928
    }
6929
6930
    if (self::str_starts_with($haystack, $needle) === true) {
6931
      $haystackTmp = self::substr($haystack, self::strlen($needle));
6932
      if ($haystackTmp === false) {
6933
        $haystackTmp = '';
6934
      }
6935
      $haystack = (string)$haystackTmp;
6936
    }
6937
6938
    return $haystack;
6939
  }
6940
6941
  /**
6942
   * Replace text within a portion of a string.
@@ 7051-7070 (lines=20) @@
7048
   *
7049
   * @return string <p>Return the sub-string.</p>
7050
   */
7051
  public static function substr_right(string $haystack, string $needle): string
7052
  {
7053
    if (!isset($haystack[0])) {
7054
      return '';
7055
    }
7056
7057
    if (!isset($needle[0])) {
7058
      return $haystack;
7059
    }
7060
7061
    if (self::str_ends_with($haystack, $needle) === true) {
7062
      $haystackTmp = self::substr($haystack, 0, self::strlen($haystack) - self::strlen($needle));
7063
      if ($haystackTmp === false) {
7064
        $haystackTmp = '';
7065
      }
7066
      $haystack = (string)$haystackTmp;
7067
    }
7068
7069
    return $haystack;
7070
  }
7071
7072
  /**
7073
   * Returns a case swapped version of the string.