Code Duplication    Length = 10-10 lines in 3 locations

src/Stringy.php 3 locations

@@ 298-307 (lines=10) @@
295
   *
296
   * @return static <p>Object with a trimmed $str.</p>
297
   */
298
  public function trim($chars = null)
299
  {
300
    if (!$chars) {
301
      $chars = '[:space:]';
302
    } else {
303
      $chars = preg_quote($chars, '/');
304
    }
305
306
    return $this->regexReplace("^[$chars]+|[$chars]+\$", '');
307
  }
308
309
  /**
310
   * Replaces all occurrences of $pattern in $str by $replacement.
@@ 2306-2315 (lines=10) @@
2303
   *
2304
   * @return static <p>Object with a trimmed $str.</p>
2305
   */
2306
  public function trimLeft($chars = null)
2307
  {
2308
    if (!$chars) {
2309
      $chars = '[:space:]';
2310
    } else {
2311
      $chars = preg_quote($chars, '/');
2312
    }
2313
2314
    return $this->regexReplace("^[$chars]+", '');
2315
  }
2316
2317
  /**
2318
   * Returns a string with whitespace removed from the end of the string.
@@ 2326-2335 (lines=10) @@
2323
   *
2324
   * @return static <p>Object with a trimmed $str.</p>
2325
   */
2326
  public function trimRight($chars = null)
2327
  {
2328
    if (!$chars) {
2329
      $chars = '[:space:]';
2330
    } else {
2331
      $chars = preg_quote($chars, '/');
2332
    }
2333
2334
    return $this->regexReplace("[$chars]+\$", '');
2335
  }
2336
2337
  /**
2338
   * Truncates the string to a given length. If $substring is provided, and