Code Duplication    Length = 20-20 lines in 4 locations

src/voku/helper/UTF8.php 4 locations

@@ 5850-5869 (lines=20) @@
5847
   *
5848
   * @return string <p>Return the sub-string.</p>
5849
   */
5850
  public static function substr_ileft(string $haystack, string $needle): string
5851
  {
5852
    if (!isset($haystack[0])) {
5853
      return '';
5854
    }
5855
5856
    if (!isset($needle[0])) {
5857
      return $haystack;
5858
    }
5859
5860
    if (self::str_istarts_with($haystack, $needle) === true) {
5861
      $haystackTmp = self::substr($haystack, self::strlen($needle));
5862
      if ($haystackTmp === false) {
5863
        $haystackTmp = '';
5864
      }
5865
      $haystack = (string)$haystackTmp;
5866
    }
5867
5868
    return $haystack;
5869
  }
5870
5871
  /**
5872
   * Removes an suffix ($needle) from end of the string ($haystack), case insensitive.
@@ 5879-5898 (lines=20) @@
5876
   *
5877
   * @return string <p>Return the sub-string.</p>
5878
   */
5879
  public static function substr_iright(string $haystack, string $needle): string
5880
  {
5881
    if (!isset($haystack[0])) {
5882
      return '';
5883
    }
5884
5885
    if (!isset($needle[0])) {
5886
      return $haystack;
5887
    }
5888
5889
    if (self::str_iends_with($haystack, $needle) === true) {
5890
      $haystackTmp = self::substr($haystack, 0, self::strlen($haystack) - self::strlen($needle));
5891
      if ($haystackTmp === false) {
5892
        $haystackTmp = '';
5893
      }
5894
      $haystack = (string)$haystackTmp;
5895
    }
5896
5897
    return $haystack;
5898
  }
5899
5900
  /**
5901
   * Removes an prefix ($needle) from start of the string ($haystack).
@@ 5908-5927 (lines=20) @@
5905
   *
5906
   * @return string <p>Return the sub-string.</p>
5907
   */
5908
  public static function substr_left(string $haystack, string $needle): string
5909
  {
5910
    if (!isset($haystack[0])) {
5911
      return '';
5912
    }
5913
5914
    if (!isset($needle[0])) {
5915
      return $haystack;
5916
    }
5917
5918
    if (self::str_starts_with($haystack, $needle) === true) {
5919
      $haystackTmp = self::substr($haystack, self::strlen($needle));
5920
      if ($haystackTmp === false) {
5921
        $haystackTmp = '';
5922
      }
5923
      $haystack = (string)$haystackTmp;
5924
    }
5925
5926
    return $haystack;
5927
  }
5928
5929
  /**
5930
   * Replace text within a portion of a string.
@@ 6039-6058 (lines=20) @@
6036
   *
6037
   * @return string <p>Return the sub-string.</p>
6038
   */
6039
  public static function substr_right(string $haystack, string $needle): string
6040
  {
6041
    if (!isset($haystack[0])) {
6042
      return '';
6043
    }
6044
6045
    if (!isset($needle[0])) {
6046
      return $haystack;
6047
    }
6048
6049
    if (self::str_ends_with($haystack, $needle) === true) {
6050
      $haystackTmp = self::substr($haystack, 0, self::strlen($haystack) - self::strlen($needle));
6051
      if ($haystackTmp === false) {
6052
        $haystackTmp = '';
6053
      }
6054
      $haystack = (string)$haystackTmp;
6055
    }
6056
6057
    return $haystack;
6058
  }
6059
6060
  /**
6061
   * Returns a case swapped version of the string.