Code Duplication    Length = 15-15 lines in 4 locations

src/voku/helper/UTF8.php 4 locations

@@ 4140-4154 (lines=15) @@
4137
   *
4138
   * @return bool
4139
   */
4140
  public static function str_ends_with($haystack, $needle)
4141
  {
4142
    $haystack = (string)$haystack;
4143
    $needle = (string)$needle;
4144
4145
    if (!isset($haystack[0], $needle[0])) {
4146
      return false;
4147
    }
4148
4149
    if ($needle === self::substr($haystack, -self::strlen($needle))) {
4150
      return true;
4151
    }
4152
4153
    return false;
4154
  }
4155
4156
  /**
4157
   * Check if the string ends with the given substring, case insensitive.
@@ 4164-4178 (lines=15) @@
4161
   *
4162
   * @return bool
4163
   */
4164
  public static function str_iends_with($haystack, $needle)
4165
  {
4166
    $haystack = (string)$haystack;
4167
    $needle = (string)$needle;
4168
4169
    if (!isset($haystack[0], $needle[0])) {
4170
      return false;
4171
    }
4172
4173
    if (self::strcasecmp(self::substr($haystack, -self::strlen($needle)), $needle) === 0) {
4174
      return true;
4175
    }
4176
4177
    return false;
4178
  }
4179
4180
  /**
4181
   * Case-insensitive and UTF-8 safe version of <function>str_replace</function>.
@@ 4232-4246 (lines=15) @@
4229
   *
4230
   * @return bool
4231
   */
4232
  public static function str_istarts_with($haystack, $needle)
4233
  {
4234
    $haystack = (string)$haystack;
4235
    $needle = (string)$needle;
4236
4237
    if (!isset($haystack[0], $needle[0])) {
4238
      return false;
4239
    }
4240
4241
    if (self::stripos($haystack, $needle) === 0) {
4242
      return true;
4243
    }
4244
4245
    return false;
4246
  }
4247
4248
  /**
4249
   * Limit the number of characters in a string, but also after the next word.
@@ 4498-4512 (lines=15) @@
4495
   *
4496
   * @return bool
4497
   */
4498
  public static function str_starts_with($haystack, $needle)
4499
  {
4500
    $haystack = (string)$haystack;
4501
    $needle = (string)$needle;
4502
4503
    if (!isset($haystack[0], $needle[0])) {
4504
      return false;
4505
    }
4506
4507
    if (self::strpos($haystack, $needle) === 0) {
4508
      return true;
4509
    }
4510
4511
    return false;
4512
  }
4513
4514
  /**
4515
   * Get a binary representation of a specific string.