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.
@@ 2000-2009 (lines=10) @@
1997
   *
1998
   * @return Stringy Object with a trimmed $str
1999
   */
2000
  public function trimLeft($chars = null)
2001
  {
2002
    if (!$chars) {
2003
      $chars = '[:space:]';
2004
    } else {
2005
      $chars = preg_quote($chars, '/');
2006
    }
2007
2008
    return $this->regexReplace("^[$chars]+", '');
2009
  }
2010
2011
  /**
2012
   * Returns a string with whitespace removed from the end of the string.
@@ 2020-2029 (lines=10) @@
2017
   *
2018
   * @return Stringy Object with a trimmed $str
2019
   */
2020
  public function trimRight($chars = null)
2021
  {
2022
    if (!$chars) {
2023
      $chars = '[:space:]';
2024
    } else {
2025
      $chars = preg_quote($chars, '/');
2026
    }
2027
2028
    return $this->regexReplace("[$chars]+\$", '');
2029
  }
2030
2031
  /**
2032
   * Truncates the string to a given length. If $substring is provided, and