Code Duplication    Length = 16-16 lines in 3 locations

src/voku/helper/UTF8.php 3 locations

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