Code Duplication    Length = 16-16 lines in 3 locations

src/voku/helper/UTF8.php 3 locations

@@ 3419-3434 (lines=16) @@
3416
   *
3417
   * @return string <p>The string with unwanted characters stripped from the left.</p>
3418
   */
3419
  public static function ltrim(string $str = '', $chars = INF): string
3420
  {
3421
    if (!isset($str[0])) {
3422
      return '';
3423
    }
3424
3425
    // Info: http://nadeausoftware.com/articles/2007/9/php_tip_how_strip_punctuation_characters_web_page#Unicodecharactercategories
3426
    if ($chars === INF || !$chars) {
3427
      $pattern = "^[\pZ\pC]+";
3428
    } else {
3429
      $chars = \preg_quote($chars, '/');
3430
      $pattern = "^[$chars]+";
3431
    }
3432
3433
    return self::regexReplace($str, $pattern, '', '', '/');
3434
  }
3435
3436
  /**
3437
   * Returns true if $str matches the supplied pattern, false otherwise.
@@ 4161-4176 (lines=16) @@
4158
   *
4159
   * @return string <p>The string with unwanted characters stripped from the right.</p>
4160
   */
4161
  public static function rtrim(string $str = '', $chars = INF): string
4162
  {
4163
    if (!isset($str[0])) {
4164
      return '';
4165
    }
4166
4167
    // Info: http://nadeausoftware.com/articles/2007/9/php_tip_how_strip_punctuation_characters_web_page#Unicodecharactercategories
4168
    if ($chars === INF || !$chars) {
4169
      $pattern = "[\pZ\pC]+\$";
4170
    } else {
4171
      $chars = \preg_quote($chars, '/');
4172
      $pattern = "[$chars]+\$";
4173
    }
4174
4175
    return self::regexReplace($str, $pattern, '', '', '/');
4176
  }
4177
4178
  /**
4179
   * rxClass
@@ 7579-7594 (lines=16) @@
7576
   *
7577
   * @return string <p>The trimmed string.</p>
7578
   */
7579
  public static function trim(string $str = '', $chars = INF): string
7580
  {
7581
    if (!isset($str[0])) {
7582
      return '';
7583
    }
7584
7585
    // Info: http://nadeausoftware.com/articles/2007/9/php_tip_how_strip_punctuation_characters_web_page#Unicodecharactercategories
7586
    if ($chars === INF || !$chars) {
7587
      $pattern = "^[\pZ\pC]+|[\pZ\pC]+\$";
7588
    } else {
7589
      $chars = \preg_quote($chars, '/');
7590
      $pattern = "^[$chars]+|[$chars]+\$";
7591
    }
7592
7593
    return self::regexReplace($str, $pattern, '', '', '/');
7594
  }
7595
7596
  /**
7597
   * Makes string's first char uppercase.