Code Duplication    Length = 15-15 lines in 4 locations

src/voku/helper/UTF8.php 4 locations

@@ 4294-4308 (lines=15) @@
4291
   *
4292
   * @return bool
4293
   */
4294
  public static function str_ends_with($haystack, $needle)
4295
  {
4296
    $haystack = (string)$haystack;
4297
    $needle = (string)$needle;
4298
4299
    if (!isset($haystack[0], $needle[0])) {
4300
      return false;
4301
    }
4302
4303
    if ($needle === self::substr($haystack, -self::strlen($needle))) {
4304
      return true;
4305
    }
4306
4307
    return false;
4308
  }
4309
4310
  /**
4311
   * Check if the string ends with the given substring, case insensitive.
@@ 4318-4332 (lines=15) @@
4315
   *
4316
   * @return bool
4317
   */
4318
  public static function str_iends_with($haystack, $needle)
4319
  {
4320
    $haystack = (string)$haystack;
4321
    $needle = (string)$needle;
4322
4323
    if (!isset($haystack[0], $needle[0])) {
4324
      return false;
4325
    }
4326
4327
    if (self::strcasecmp(self::substr($haystack, -self::strlen($needle)), $needle) === 0) {
4328
      return true;
4329
    }
4330
4331
    return false;
4332
  }
4333
4334
  /**
4335
   * Case-insensitive and UTF-8 safe version of <function>str_replace</function>.
@@ 4386-4400 (lines=15) @@
4383
   *
4384
   * @return bool
4385
   */
4386
  public static function str_istarts_with($haystack, $needle)
4387
  {
4388
    $haystack = (string)$haystack;
4389
    $needle = (string)$needle;
4390
4391
    if (!isset($haystack[0], $needle[0])) {
4392
      return false;
4393
    }
4394
4395
    if (self::stripos($haystack, $needle) === 0) {
4396
      return true;
4397
    }
4398
4399
    return false;
4400
  }
4401
4402
  /**
4403
   * Limit the number of characters in a string, but also after the next word.
@@ 4672-4686 (lines=15) @@
4669
   *
4670
   * @return bool
4671
   */
4672
  public static function str_starts_with($haystack, $needle)
4673
  {
4674
    $haystack = (string)$haystack;
4675
    $needle = (string)$needle;
4676
4677
    if (!isset($haystack[0], $needle[0])) {
4678
      return false;
4679
    }
4680
4681
    if (self::strpos($haystack, $needle) === 0) {
4682
      return true;
4683
    }
4684
4685
    return false;
4686
  }
4687
4688
  /**
4689
   * Get a binary representation of a specific string.