Code Duplication    Length = 12-12 lines in 4 locations

src/Stringy.php 4 locations

@@ 1592-1603 (lines=12) @@
1589
   *
1590
   * @return static
1591
   */
1592
  public function substringOf(string $needle, bool $beforeNeedle = false): self
1593
  {
1594
    if ('' === $needle) {
1595
      return static::create();
1596
    }
1597
1598
    if (false === $part = UTF8::strstr($this->str, $needle, $beforeNeedle, $this->encoding)) {
1599
      return static::create();
1600
    }
1601
1602
    return static::create($part);
1603
  }
1604
1605
  /**
1606
   * Gets the substring after (or before via "$beforeNeedle") the first occurrence of the "$needle".
@@ 1614-1625 (lines=12) @@
1611
   *
1612
   * @return static
1613
   */
1614
  public function substringOfIgnoreCase(string $needle, bool $beforeNeedle = false): self
1615
  {
1616
    if ('' === $needle) {
1617
      return static::create();
1618
    }
1619
1620
    if (false === $part = UTF8::stristr($this->str, $needle, $beforeNeedle, $this->encoding)) {
1621
      return static::create();
1622
    }
1623
1624
    return static::create($part);
1625
  }
1626
1627
  /**
1628
   * Gets the substring after (or before via "$beforeNeedle") the last occurrence of the "$needle".
@@ 1636-1647 (lines=12) @@
1633
   *
1634
   * @return static
1635
   */
1636
  public function lastSubstringOf(string $needle, bool $beforeNeedle = false): self
1637
  {
1638
    if ('' === $needle) {
1639
      return static::create();
1640
    }
1641
1642
    if (false === $part = UTF8::strrchr($this->str, $needle, $beforeNeedle, $this->encoding)) {
1643
      return static::create();
1644
    }
1645
1646
    return static::create($part);
1647
  }
1648
1649
  /**
1650
   * Gets the substring after (or before via "$beforeNeedle") the last occurrence of the "$needle".
@@ 1658-1669 (lines=12) @@
1655
   *
1656
   * @return static
1657
   */
1658
  public function lastSubstringOfIgnoreCase(string $needle, bool $beforeNeedle = false): self
1659
  {
1660
    if ('' === $needle) {
1661
      return static::create();
1662
    }
1663
1664
    if (false === $part = UTF8::strrichr($this->str, $needle, $beforeNeedle, $this->encoding)) {
1665
      return static::create();
1666
    }
1667
1668
    return static::create($part);
1669
  }
1670
1671
  /**
1672
   * Returns a reversed string. A multibyte version of strrev().