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.
@@ 1705-1714 (lines=10) @@
1702
   *
1703
   * @return Stringy Object with a trimmed $str
1704
   */
1705
  public function trimLeft($chars = null)
1706
  {
1707
    if (!$chars) {
1708
      $chars = '[:space:]';
1709
    } else {
1710
      $chars = preg_quote($chars, '/');
1711
    }
1712
1713
    return $this->regexReplace("^[$chars]+", '');
1714
  }
1715
1716
  /**
1717
   * Returns a string with whitespace removed from the end of the string.
@@ 1725-1734 (lines=10) @@
1722
   *
1723
   * @return Stringy Object with a trimmed $str
1724
   */
1725
  public function trimRight($chars = null)
1726
  {
1727
    if (!$chars) {
1728
      $chars = '[:space:]';
1729
    } else {
1730
      $chars = preg_quote($chars, '/');
1731
    }
1732
1733
    return $this->regexReplace("[$chars]+\$", '');
1734
  }
1735
1736
  /**
1737
   * Truncates the string to a given length. If $substring is provided, and