Code Duplication    Length = 13-13 lines in 2 locations

src/voku/helper/UTF8.php 2 locations

@@ 2819-2831 (lines=13) @@
2816
   *
2817
   * @return string <p>The string with unwanted characters stripped from the left.</p>
2818
   */
2819
  public static function ltrim(string $str = '', $chars = INF): string
2820
  {
2821
    if (!isset($str[0])) {
2822
      return '';
2823
    }
2824
2825
    // Info: http://nadeausoftware.com/articles/2007/9/php_tip_how_strip_punctuation_characters_web_page#Unicodecharactercategories
2826
    if ($chars === INF || !$chars) {
2827
      return \preg_replace('/^[\pZ\pC]+/u', '', $str);
2828
    }
2829
2830
    return \preg_replace('/^' . self::rxClass($chars) . '+/u', '', $str);
2831
  }
2832
2833
  /**
2834
   * Returns the UTF-8 character with the maximum code point in the given data.
@@ 3470-3482 (lines=13) @@
3467
   *
3468
   * @return string <p>The string with unwanted characters stripped from the right.</p>
3469
   */
3470
  public static function rtrim(string $str = '', $chars = INF): string
3471
  {
3472
    if (!isset($str[0])) {
3473
      return '';
3474
    }
3475
3476
    // Info: http://nadeausoftware.com/articles/2007/9/php_tip_how_strip_punctuation_characters_web_page#Unicodecharactercategories
3477
    if ($chars === INF || !$chars) {
3478
      return \preg_replace('/[\pZ\pC]+$/u', '', $str);
3479
    }
3480
3481
    return \preg_replace('/' . self::rxClass($chars) . '+$/u', '', $str);
3482
  }
3483
3484
  /**
3485
   * rxClass