Code Duplication    Length = 15-15 lines in 4 locations

src/voku/helper/UTF8.php 4 locations

@@ 4024-4038 (lines=15) @@
4021
   *
4022
   * @return bool
4023
   */
4024
  public static function str_ends_with($haystack, $needle)
4025
  {
4026
    $haystack = (string)$haystack;
4027
    $needle = (string)$needle;
4028
4029
    if (!isset($haystack[0], $needle[0])) {
4030
      return false;
4031
    }
4032
4033
    if ($needle === self::substr($haystack, -self::strlen($needle))) {
4034
      return true;
4035
    }
4036
4037
    return false;
4038
  }
4039
4040
  /**
4041
   * Check if the string ends with the given substring, case insensitive.
@@ 4048-4062 (lines=15) @@
4045
   *
4046
   * @return bool
4047
   */
4048
  public static function str_iends_with($haystack, $needle)
4049
  {
4050
    $haystack = (string)$haystack;
4051
    $needle = (string)$needle;
4052
4053
    if (!isset($haystack[0], $needle[0])) {
4054
      return false;
4055
    }
4056
4057
    if (self::strcasecmp(self::substr($haystack, -self::strlen($needle)), $needle) === 0) {
4058
      return true;
4059
    }
4060
4061
    return false;
4062
  }
4063
4064
  /**
4065
   * Case-insensitive and UTF-8 safe version of <function>str_replace</function>.
@@ 4116-4130 (lines=15) @@
4113
   *
4114
   * @return bool
4115
   */
4116
  public static function str_istarts_with($haystack, $needle)
4117
  {
4118
    $haystack = (string)$haystack;
4119
    $needle = (string)$needle;
4120
4121
    if (!isset($haystack[0], $needle[0])) {
4122
      return false;
4123
    }
4124
4125
    if (self::stripos($haystack, $needle) === 0) {
4126
      return true;
4127
    }
4128
4129
    return false;
4130
  }
4131
4132
  /**
4133
   * Limit the number of characters in a string, but also after the next word.
@@ 4382-4396 (lines=15) @@
4379
   *
4380
   * @return bool
4381
   */
4382
  public static function str_starts_with($haystack, $needle)
4383
  {
4384
    $haystack = (string)$haystack;
4385
    $needle = (string)$needle;
4386
4387
    if (!isset($haystack[0], $needle[0])) {
4388
      return false;
4389
    }
4390
4391
    if (self::strpos($haystack, $needle) === 0) {
4392
      return true;
4393
    }
4394
4395
    return false;
4396
  }
4397
4398
  /**
4399
   * Get a binary representation of a specific string.