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.
@@ 1831-1840 (lines=10) @@
1828
   *
1829
   * @return Stringy Object with a trimmed $str
1830
   */
1831
  public function trimLeft($chars = null)
1832
  {
1833
    if (!$chars) {
1834
      $chars = '[:space:]';
1835
    } else {
1836
      $chars = preg_quote($chars, '/');
1837
    }
1838
1839
    return $this->regexReplace("^[$chars]+", '');
1840
  }
1841
1842
  /**
1843
   * Returns a string with whitespace removed from the end of the string.
@@ 1851-1860 (lines=10) @@
1848
   *
1849
   * @return Stringy Object with a trimmed $str
1850
   */
1851
  public function trimRight($chars = null)
1852
  {
1853
    if (!$chars) {
1854
      $chars = '[:space:]';
1855
    } else {
1856
      $chars = preg_quote($chars, '/');
1857
    }
1858
1859
    return $this->regexReplace("[$chars]+\$", '');
1860
  }
1861
1862
  /**
1863
   * Truncates the string to a given length. If $substring is provided, and