Code Duplication    Length = 10-10 lines in 3 locations

src/Stringy.php 3 locations

@@ 276-285 (lines=10) @@
273
   *
274
   * @return Stringy Object with a trimmed $str
275
   */
276
  public function trim($chars = null)
277
  {
278
    if (!$chars) {
279
      $chars = '[:space:]';
280
    } else {
281
      $chars = preg_quote($chars, '/');
282
    }
283
284
    return $this->regexReplace("^[$chars]+|[$chars]+\$", '');
285
  }
286
287
  /**
288
   * Replaces all occurrences of $pattern in $str by $replacement.
@@ 1980-1989 (lines=10) @@
1977
   *
1978
   * @return Stringy Object with a trimmed $str
1979
   */
1980
  public function trimLeft($chars = null)
1981
  {
1982
    if (!$chars) {
1983
      $chars = '[:space:]';
1984
    } else {
1985
      $chars = preg_quote($chars, '/');
1986
    }
1987
1988
    return $this->regexReplace("^[$chars]+", '');
1989
  }
1990
1991
  /**
1992
   * Returns a string with whitespace removed from the end of the string.
@@ 2000-2009 (lines=10) @@
1997
   *
1998
   * @return Stringy Object with a trimmed $str
1999
   */
2000
  public function trimRight($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
   * Truncates the string to a given length. If $substring is provided, and