Code Duplication    Length = 10-10 lines in 3 locations

src/Stringy.php 3 locations

@@ 278-287 (lines=10) @@
275
   *
276
   * @return Stringy Object with a trimmed $str
277
   */
278
  public function trim($chars = null)
279
  {
280
    if (!$chars) {
281
      $chars = '[:space:]';
282
    } else {
283
      $chars = preg_quote($chars, '/');
284
    }
285
286
    return $this->regexReplace("^[$chars]+|[$chars]+\$", '');
287
  }
288
289
  /**
290
   * Replaces all occurrences of $pattern in $str by $replacement.
@@ 1996-2005 (lines=10) @@
1993
   *
1994
   * @return Stringy Object with a trimmed $str
1995
   */
1996
  public function trimLeft($chars = null)
1997
  {
1998
    if (!$chars) {
1999
      $chars = '[:space:]';
2000
    } else {
2001
      $chars = preg_quote($chars, '/');
2002
    }
2003
2004
    return $this->regexReplace("^[$chars]+", '');
2005
  }
2006
2007
  /**
2008
   * Returns a string with whitespace removed from the end of the string.
@@ 2016-2025 (lines=10) @@
2013
   *
2014
   * @return Stringy Object with a trimmed $str
2015
   */
2016
  public function trimRight($chars = null)
2017
  {
2018
    if (!$chars) {
2019
      $chars = '[:space:]';
2020
    } else {
2021
      $chars = preg_quote($chars, '/');
2022
    }
2023
2024
    return $this->regexReplace("[$chars]+\$", '');
2025
  }
2026
2027
  /**
2028
   * Truncates the string to a given length. If $substring is provided, and