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