Code Duplication    Length = 13-13 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 2721-2733 (lines=13) @@
2718
   *
2719
   * @return string <p>The string with unwanted characters stripped from the left.</p>
2720
   */
2721
  public static function ltrim(string $str = '', $chars = INF): string
2722
  {
2723
    if (!isset($str[0])) {
2724
      return '';
2725
    }
2726
2727
    // Info: http://nadeausoftware.com/articles/2007/9/php_tip_how_strip_punctuation_characters_web_page#Unicodecharactercategories
2728
    if ($chars === INF || !$chars) {
2729
      return \preg_replace('/^[\pZ\pC]+/u', '', $str);
2730
    }
2731
2732
    return \preg_replace('/^' . self::rxClass($chars) . '+/u', '', $str);
2733
  }
2734
2735
  /**
2736
   * Returns the UTF-8 character with the maximum code point in the given data.
@@ 3391-3403 (lines=13) @@
3388
   *
3389
   * @return string <p>The string with unwanted characters stripped from the right.</p>
3390
   */
3391
  public static function rtrim(string $str = '', $chars = INF): string
3392
  {
3393
    if (!isset($str[0])) {
3394
      return '';
3395
    }
3396
3397
    // Info: http://nadeausoftware.com/articles/2007/9/php_tip_how_strip_punctuation_characters_web_page#Unicodecharactercategories
3398
    if ($chars === INF || !$chars) {
3399
      return \preg_replace('/[\pZ\pC]+$/u', '', $str);
3400
    }
3401
3402
    return \preg_replace('/' . self::rxClass($chars) . '+$/u', '', $str);
3403
  }
3404
3405
  /**
3406
   * rxClass