Code Duplication    Length = 12-12 lines in 4 locations

src/voku/helper/UTF8.php 4 locations

@@ 3807-3818 (lines=12) @@
3804
   *
3805
   * @return bool
3806
   */
3807
  public static function str_ends_with(string $haystack, string $needle): bool
3808
  {
3809
    if (!isset($haystack[0], $needle[0])) {
3810
      return false;
3811
    }
3812
3813
    if (\substr($haystack, -\strlen($needle)) === $needle) {
3814
      return true;
3815
    }
3816
3817
    return false;
3818
  }
3819
3820
  /**
3821
   * Check if the string ends with the given substring, case insensitive.
@@ 3828-3839 (lines=12) @@
3825
   *
3826
   * @return bool
3827
   */
3828
  public static function str_iends_with(string $haystack, string $needle): bool
3829
  {
3830
    if (!isset($haystack[0], $needle[0])) {
3831
      return false;
3832
    }
3833
3834
    if (self::strcasecmp(\substr($haystack, -\strlen($needle)), $needle) === 0) {
3835
      return true;
3836
    }
3837
3838
    return false;
3839
  }
3840
3841
  /**
3842
   * Case-insensitive and UTF-8 safe version of <function>str_replace</function>.
@@ 3893-3904 (lines=12) @@
3890
   *
3891
   * @return bool
3892
   */
3893
  public static function str_istarts_with(string $haystack, string $needle): bool
3894
  {
3895
    if (!isset($haystack[0], $needle[0])) {
3896
      return false;
3897
    }
3898
3899
    if (self::stripos($haystack, $needle) === 0) {
3900
      return true;
3901
    }
3902
3903
    return false;
3904
  }
3905
3906
  /**
3907
   * Limit the number of characters in a string, but also after the next word.
@@ 4176-4187 (lines=12) @@
4173
   *
4174
   * @return bool
4175
   */
4176
  public static function str_starts_with(string $haystack, string $needle): bool
4177
  {
4178
    if (!isset($haystack[0], $needle[0])) {
4179
      return false;
4180
    }
4181
4182
    if (\strpos($haystack, $needle) === 0) {
4183
      return true;
4184
    }
4185
4186
    return false;
4187
  }
4188
4189
  /**
4190
   * Get a binary representation of a specific string.