Code Duplication    Length = 12-12 lines in 4 locations

src/Stringy.php 4 locations

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