Code Duplication    Length = 16-17 lines in 3 locations

src/Stringy.php 3 locations

@@ 2206-2221 (lines=16) @@
2203
   *
2204
   * @return Stringy
2205
   */
2206
  public function afterFirst($separator)
2207
  {
2208
    if (($offset = $this->indexOf($separator)) === false) {
2209
      return static::create('');
2210
    }
2211
2212
    return static::create(
2213
        UTF8::substr(
2214
            $this->str,
2215
            $offset + UTF8::strlen($separator, $this->encoding),
2216
            null,
2217
            $this->encoding
2218
        ),
2219
        $this->encoding
2220
    );
2221
  }
2222
2223
  /**
2224
   * Gets the substring after the last occurrence of a separator.
@@ 2257-2273 (lines=17) @@
2254
   *
2255
   * @return Stringy
2256
   */
2257
  public function beforeFirst($separator)
2258
  {
2259
    $offset = $this->indexOf($separator);
2260
    if ($offset === false) {
2261
      return static::create('', $this->encoding);
2262
    }
2263
2264
    return static::create(
2265
        UTF8::substr(
2266
            $this->str,
2267
            0,
2268
            $offset,
2269
            $this->encoding
2270
        ),
2271
        $this->encoding
2272
    );
2273
  }
2274
2275
  /**
2276
   * Gets the substring before the last occurrence of a separator.
@@ 2283-2299 (lines=17) @@
2280
   *
2281
   * @return Stringy
2282
   */
2283
  public function beforeLast($separator)
2284
  {
2285
    $offset = $this->indexOfLast($separator);
2286
    if ($offset === false) {
2287
      return static::create('', $this->encoding);
2288
    }
2289
2290
    return static::create(
2291
        UTF8::substr(
2292
            $this->str,
2293
            0,
2294
            $offset,
2295
            $this->encoding
2296
        ),
2297
        $this->encoding
2298
    );
2299
  }
2300
2301
  /**
2302
   * Returns the string with the first letter of each word capitalized,