Code Duplication    Length = 12-12 lines in 4 locations

src/Stringy.php 4 locations

@@ 1511-1522 (lines=12) @@
1508
   *
1509
   * @return static
1510
   */
1511
  public function substringOf($needle, $beforeNeedle = false)
1512
  {
1513
    if ('' === $needle) {
1514
      return static::create('');
1515
    }
1516
1517
    if (false === $part = UTF8::strstr($this->str, $needle, $beforeNeedle, $this->encoding)) {
1518
      return static::create('');
1519
    }
1520
1521
    return static::create($part);
1522
  }
1523
1524
  /**
1525
   * Gets the substring after (or before via "$beforeNeedle") the first occurrence of the "$needle".
@@ 1533-1544 (lines=12) @@
1530
   *
1531
   * @return static
1532
   */
1533
  public function substringOfIgnoreCase($needle, $beforeNeedle = false)
1534
  {
1535
    if ('' === $needle) {
1536
      return static::create('');
1537
    }
1538
1539
    if (false === $part = UTF8::stristr($this->str, $needle, $beforeNeedle, $this->encoding)) {
1540
      return static::create('');
1541
    }
1542
1543
    return static::create($part);
1544
  }
1545
1546
  /**
1547
   * Gets the substring after (or before via "$beforeNeedle") the last occurrence of the "$needle".
@@ 1555-1566 (lines=12) @@
1552
   *
1553
   * @return static
1554
   */
1555
  public function lastSubstringOf($needle, $beforeNeedle = false)
1556
  {
1557
    if ('' === $needle) {
1558
      return static::create('');
1559
    }
1560
1561
    if (false === $part = UTF8::strrchr($this->str, $needle, $beforeNeedle, $this->encoding)) {
1562
      return static::create('');
1563
    }
1564
1565
    return static::create($part);
1566
  }
1567
1568
  /**
1569
   * Gets the substring after (or before via "$beforeNeedle") the last occurrence of the "$needle".
@@ 1577-1588 (lines=12) @@
1574
   *
1575
   * @return static
1576
   */
1577
  public function lastSubstringOfIgnoreCase($needle, $beforeNeedle = false)
1578
  {
1579
    if ('' === $needle) {
1580
      return static::create('');
1581
    }
1582
1583
    if (false === $part = UTF8::strrichr($this->str, $needle, $beforeNeedle, $this->encoding)) {
1584
      return static::create('');
1585
    }
1586
1587
    return static::create($part);
1588
  }
1589
1590
  /**
1591
   * Returns a reversed string. A multibyte version of strrev().