Code Duplication    Length = 16-16 lines in 3 locations

src/voku/helper/UTF8.php 3 locations

@@ 3412-3427 (lines=16) @@
3409
   *
3410
   * @return string <p>The string with unwanted characters stripped from the left.</p>
3411
   */
3412
  public static function ltrim(string $str = '', $chars = INF): string
3413
  {
3414
    if (!isset($str[0])) {
3415
      return '';
3416
    }
3417
3418
    // Info: http://nadeausoftware.com/articles/2007/9/php_tip_how_strip_punctuation_characters_web_page#Unicodecharactercategories
3419
    if ($chars === INF || !$chars) {
3420
      $pattern = "^[\pZ\pC]+";
3421
    } else {
3422
      $chars = \preg_quote($chars, '/');
3423
      $pattern = "^[$chars]+";
3424
    }
3425
3426
    return self::regexReplace($str, $pattern, '', '', '/');
3427
  }
3428
3429
  /**
3430
   * Returns true if $str matches the supplied pattern, false otherwise.
@@ 4154-4169 (lines=16) @@
4151
   *
4152
   * @return string <p>The string with unwanted characters stripped from the right.</p>
4153
   */
4154
  public static function rtrim(string $str = '', $chars = INF): string
4155
  {
4156
    if (!isset($str[0])) {
4157
      return '';
4158
    }
4159
4160
    // Info: http://nadeausoftware.com/articles/2007/9/php_tip_how_strip_punctuation_characters_web_page#Unicodecharactercategories
4161
    if ($chars === INF || !$chars) {
4162
      $pattern = "[\pZ\pC]+\$";
4163
    } else {
4164
      $chars = \preg_quote($chars, '/');
4165
      $pattern = "[$chars]+\$";
4166
    }
4167
4168
    return self::regexReplace($str, $pattern, '', '', '/');
4169
  }
4170
4171
  /**
4172
   * rxClass
@@ 7572-7587 (lines=16) @@
7569
   *
7570
   * @return string <p>The trimmed string.</p>
7571
   */
7572
  public static function trim(string $str = '', $chars = INF): string
7573
  {
7574
    if (!isset($str[0])) {
7575
      return '';
7576
    }
7577
7578
    // Info: http://nadeausoftware.com/articles/2007/9/php_tip_how_strip_punctuation_characters_web_page#Unicodecharactercategories
7579
    if ($chars === INF || !$chars) {
7580
      $pattern = "^[\pZ\pC]+|[\pZ\pC]+\$";
7581
    } else {
7582
      $chars = \preg_quote($chars, '/');
7583
      $pattern = "^[$chars]+|[$chars]+\$";
7584
    }
7585
7586
    return self::regexReplace($str, $pattern, '', '', '/');
7587
  }
7588
7589
  /**
7590
   * Makes string's first char uppercase.