Code Duplication    Length = 16-17 lines in 3 locations

src/Stringy.php 3 locations

@@ 2222-2237 (lines=16) @@
2219
   *
2220
   * @return Stringy
2221
   */
2222
  public function afterFirst($separator)
2223
  {
2224
    if (($offset = $this->indexOf($separator)) === false) {
2225
      return static::create('');
2226
    }
2227
2228
    return static::create(
2229
        UTF8::substr(
2230
            $this->str,
2231
            $offset + UTF8::strlen($separator, $this->encoding),
2232
            null,
2233
            $this->encoding
2234
        ),
2235
        $this->encoding
2236
    );
2237
  }
2238
2239
  /**
2240
   * Gets the substring after the last occurrence of a separator.
@@ 2273-2289 (lines=17) @@
2270
   *
2271
   * @return Stringy
2272
   */
2273
  public function beforeFirst($separator)
2274
  {
2275
    $offset = $this->indexOf($separator);
2276
    if ($offset === false) {
2277
      return static::create('', $this->encoding);
2278
    }
2279
2280
    return static::create(
2281
        UTF8::substr(
2282
            $this->str,
2283
            0,
2284
            $offset,
2285
            $this->encoding
2286
        ),
2287
        $this->encoding
2288
    );
2289
  }
2290
2291
  /**
2292
   * Gets the substring before the last occurrence of a separator.
@@ 2299-2315 (lines=17) @@
2296
   *
2297
   * @return Stringy
2298
   */
2299
  public function beforeLast($separator)
2300
  {
2301
    $offset = $this->indexOfLast($separator);
2302
    if ($offset === false) {
2303
      return static::create('', $this->encoding);
2304
    }
2305
2306
    return static::create(
2307
        UTF8::substr(
2308
            $this->str,
2309
            0,
2310
            $offset,
2311
            $this->encoding
2312
        ),
2313
        $this->encoding
2314
    );
2315
  }
2316
2317
  /**
2318
   * Returns the string with the first letter of each word capitalized,