Code Duplication    Length = 16-17 lines in 3 locations

src/Stringy.php 3 locations

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