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.
@@ 1719-1728 (lines=10) @@
1716
   *
1717
   * @return Stringy Object with a trimmed $str
1718
   */
1719
  public function trimLeft($chars = null)
1720
  {
1721
    if (!$chars) {
1722
      $chars = '[:space:]';
1723
    } else {
1724
      $chars = preg_quote($chars, '/');
1725
    }
1726
1727
    return $this->regexReplace("^[$chars]+", '');
1728
  }
1729
1730
  /**
1731
   * Returns a string with whitespace removed from the end of the string.
@@ 1739-1748 (lines=10) @@
1736
   *
1737
   * @return Stringy Object with a trimmed $str
1738
   */
1739
  public function trimRight($chars = null)
1740
  {
1741
    if (!$chars) {
1742
      $chars = '[:space:]';
1743
    } else {
1744
      $chars = preg_quote($chars, '/');
1745
    }
1746
1747
    return $this->regexReplace("[$chars]+\$", '');
1748
  }
1749
1750
  /**
1751
   * Truncates the string to a given length. If $substring is provided, and