Code Duplication    Length = 12-12 lines in 4 locations

src/Stringy.php 4 locations

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