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.
@@ 1935-1944 (lines=10) @@
1932
   *
1933
   * @return Stringy Object with a trimmed $str
1934
   */
1935
  public function trimLeft($chars = null)
1936
  {
1937
    if (!$chars) {
1938
      $chars = '[:space:]';
1939
    } else {
1940
      $chars = preg_quote($chars, '/');
1941
    }
1942
1943
    return $this->regexReplace("^[$chars]+", '');
1944
  }
1945
1946
  /**
1947
   * Returns a string with whitespace removed from the end of the string.
@@ 1955-1964 (lines=10) @@
1952
   *
1953
   * @return Stringy Object with a trimmed $str
1954
   */
1955
  public function trimRight($chars = null)
1956
  {
1957
    if (!$chars) {
1958
      $chars = '[:space:]';
1959
    } else {
1960
      $chars = preg_quote($chars, '/');
1961
    }
1962
1963
    return $this->regexReplace("[$chars]+\$", '');
1964
  }
1965
1966
  /**
1967
   * Truncates the string to a given length. If $substring is provided, and