Code Duplication    Length = 10-10 lines in 3 locations

src/Stringy.php 3 locations

@@ 299-308 (lines=10) @@
296
   *
297
   * @return static  Object with a trimmed $str
298
   */
299
  public function trim($chars = null)
300
  {
301
    if (!$chars) {
302
      $chars = '[:space:]';
303
    } else {
304
      $chars = preg_quote($chars, '/');
305
    }
306
307
    return $this->regexReplace("^[$chars]+|[$chars]+\$", '');
308
  }
309
310
  /**
311
   * Replaces all occurrences of $pattern in $str by $replacement.
@@ 2212-2221 (lines=10) @@
2209
   *
2210
   * @return static  Object with a trimmed $str
2211
   */
2212
  public function trimLeft($chars = null)
2213
  {
2214
    if (!$chars) {
2215
      $chars = '[:space:]';
2216
    } else {
2217
      $chars = preg_quote($chars, '/');
2218
    }
2219
2220
    return $this->regexReplace("^[$chars]+", '');
2221
  }
2222
2223
  /**
2224
   * Returns a string with whitespace removed from the end of the string.
@@ 2232-2241 (lines=10) @@
2229
   *
2230
   * @return static  Object with a trimmed $str
2231
   */
2232
  public function trimRight($chars = null)
2233
  {
2234
    if (!$chars) {
2235
      $chars = '[:space:]';
2236
    } else {
2237
      $chars = preg_quote($chars, '/');
2238
    }
2239
2240
    return $this->regexReplace("[$chars]+\$", '');
2241
  }
2242
2243
  /**
2244
   * Truncates the string to a given length. If $substring is provided, and