Code Duplication    Length = 15-15 lines in 4 locations

src/voku/helper/UTF8.php 4 locations

@@ 4221-4235 (lines=15) @@
4218
   *
4219
   * @return bool
4220
   */
4221
  public static function str_ends_with($haystack, $needle)
4222
  {
4223
    $haystack = (string)$haystack;
4224
    $needle = (string)$needle;
4225
4226
    if (!isset($haystack[0], $needle[0])) {
4227
      return false;
4228
    }
4229
4230
    if ($needle === self::substr($haystack, -self::strlen($needle))) {
4231
      return true;
4232
    }
4233
4234
    return false;
4235
  }
4236
4237
  /**
4238
   * Check if the string ends with the given substring, case insensitive.
@@ 4245-4259 (lines=15) @@
4242
   *
4243
   * @return bool
4244
   */
4245
  public static function str_iends_with($haystack, $needle)
4246
  {
4247
    $haystack = (string)$haystack;
4248
    $needle = (string)$needle;
4249
4250
    if (!isset($haystack[0], $needle[0])) {
4251
      return false;
4252
    }
4253
4254
    if (self::strcasecmp(self::substr($haystack, -self::strlen($needle)), $needle) === 0) {
4255
      return true;
4256
    }
4257
4258
    return false;
4259
  }
4260
4261
  /**
4262
   * Case-insensitive and UTF-8 safe version of <function>str_replace</function>.
@@ 4313-4327 (lines=15) @@
4310
   *
4311
   * @return bool
4312
   */
4313
  public static function str_istarts_with($haystack, $needle)
4314
  {
4315
    $haystack = (string)$haystack;
4316
    $needle = (string)$needle;
4317
4318
    if (!isset($haystack[0], $needle[0])) {
4319
      return false;
4320
    }
4321
4322
    if (self::stripos($haystack, $needle) === 0) {
4323
      return true;
4324
    }
4325
4326
    return false;
4327
  }
4328
4329
  /**
4330
   * Limit the number of characters in a string, but also after the next word.
@@ 4599-4613 (lines=15) @@
4596
   *
4597
   * @return bool
4598
   */
4599
  public static function str_starts_with($haystack, $needle)
4600
  {
4601
    $haystack = (string)$haystack;
4602
    $needle = (string)$needle;
4603
4604
    if (!isset($haystack[0], $needle[0])) {
4605
      return false;
4606
    }
4607
4608
    if (self::strpos($haystack, $needle) === 0) {
4609
      return true;
4610
    }
4611
4612
    return false;
4613
  }
4614
4615
  /**
4616
   * Get a binary representation of a specific string.