Code Duplication    Length = 16-17 lines in 3 locations

src/Stringy.php 3 locations

@@ 2318-2333 (lines=16) @@
2315
   *
2316
   * @return static
2317
   */
2318
  public function afterFirst($separator)
2319
  {
2320
    if (($offset = $this->indexOf($separator)) === false) {
2321
      return static::create('');
2322
    }
2323
2324
    return static::create(
2325
        UTF8::substr(
2326
            $this->str,
2327
            $offset + UTF8::strlen($separator, $this->encoding),
2328
            null,
2329
            $this->encoding
2330
        ),
2331
        $this->encoding
2332
    );
2333
  }
2334
2335
  /**
2336
   * Gets the substring after the last occurrence of a separator.
@@ 2369-2385 (lines=17) @@
2366
   *
2367
   * @return static
2368
   */
2369
  public function beforeFirst($separator)
2370
  {
2371
    $offset = $this->indexOf($separator);
2372
    if ($offset === false) {
2373
      return static::create('', $this->encoding);
2374
    }
2375
2376
    return static::create(
2377
        UTF8::substr(
2378
            $this->str,
2379
            0,
2380
            $offset,
2381
            $this->encoding
2382
        ),
2383
        $this->encoding
2384
    );
2385
  }
2386
2387
  /**
2388
   * Gets the substring before the last occurrence of a separator.
@@ 2395-2411 (lines=17) @@
2392
   *
2393
   * @return static
2394
   */
2395
  public function beforeLast($separator)
2396
  {
2397
    $offset = $this->indexOfLast($separator);
2398
    if ($offset === false) {
2399
      return static::create('', $this->encoding);
2400
    }
2401
2402
    return static::create(
2403
        UTF8::substr(
2404
            $this->str,
2405
            0,
2406
            $offset,
2407
            $this->encoding
2408
        ),
2409
        $this->encoding
2410
    );
2411
  }
2412
2413
  /**
2414
   * Returns the string with the first letter of each word capitalized,