Code Duplication    Length = 10-10 lines in 3 locations

src/Stringy.php 3 locations

@@ 214-223 (lines=10) @@
211
   *
212
   * @return Stringy Object with a trimmed $str
213
   */
214
  public function trim($chars = null)
215
  {
216
    if (!$chars) {
217
      $chars = '[:space:]';
218
    } else {
219
      $chars = preg_quote($chars, '/');
220
    }
221
222
    return $this->regexReplace("^[$chars]+|[$chars]+\$", '');
223
  }
224
225
  /**
226
   * Replaces all occurrences of $pattern in $str by $replacement.
@@ 1746-1755 (lines=10) @@
1743
   *
1744
   * @return Stringy Object with a trimmed $str
1745
   */
1746
  public function trimLeft($chars = null)
1747
  {
1748
    if (!$chars) {
1749
      $chars = '[:space:]';
1750
    } else {
1751
      $chars = preg_quote($chars, '/');
1752
    }
1753
1754
    return $this->regexReplace("^[$chars]+", '');
1755
  }
1756
1757
  /**
1758
   * Returns a string with whitespace removed from the end of the string.
@@ 1766-1775 (lines=10) @@
1763
   *
1764
   * @return Stringy Object with a trimmed $str
1765
   */
1766
  public function trimRight($chars = null)
1767
  {
1768
    if (!$chars) {
1769
      $chars = '[:space:]';
1770
    } else {
1771
      $chars = preg_quote($chars, '/');
1772
    }
1773
1774
    return $this->regexReplace("[$chars]+\$", '');
1775
  }
1776
1777
  /**
1778
   * Truncates the string to a given length. If $substring is provided, and