Code Duplication    Length = 23-24 lines in 4 locations

src/voku/helper/UTF8.php 4 locations

@@ 6617-6640 (lines=24) @@
6614
   *
6615
   * @return string <p>Return the sub-string.</p>
6616
   */
6617
  public static function substr_ileft($haystack, $needle)
6618
  {
6619
    // init
6620
    $haystack = (string)$haystack;
6621
    $needle = (string)$needle;
6622
6623
    if (!isset($haystack[0])) {
6624
      return '';
6625
    }
6626
6627
    if (!isset($needle[0])) {
6628
      return $haystack;
6629
    }
6630
6631
    if (self::str_istarts_with($haystack, $needle) === true) {
6632
      $haystackTmp = self::substr($haystack, self::strlen($needle));
6633
      if ($haystackTmp === false) {
6634
        $haystackTmp = '';
6635
      }
6636
      $haystack = (string)$haystackTmp;
6637
    }
6638
6639
    return $haystack;
6640
  }
6641
6642
  /**
6643
   * Removes an suffix ($needle) from end of the string ($haystack), case insensitive.
@@ 6650-6673 (lines=24) @@
6647
   *
6648
   * @return string <p>Return the sub-string.</p>
6649
   */
6650
  public static function substr_iright($haystack, $needle)
6651
  {
6652
    // init
6653
    $haystack = (string)$haystack;
6654
    $needle = (string)$needle;
6655
6656
    if (!isset($haystack[0])) {
6657
      return '';
6658
    }
6659
6660
    if (!isset($needle[0])) {
6661
      return $haystack;
6662
    }
6663
6664
    if (self::str_iends_with($haystack, $needle) === true) {
6665
      $haystackTmp = self::substr($haystack, 0, self::strlen($haystack) - self::strlen($needle));
6666
      if ($haystackTmp === false) {
6667
        $haystackTmp = '';
6668
      }
6669
      $haystack = (string)$haystackTmp;
6670
    }
6671
6672
    return $haystack;
6673
  }
6674
6675
  /**
6676
   * Removes an prefix ($needle) from start of the string ($haystack).
@@ 6683-6706 (lines=24) @@
6680
   *
6681
   * @return string <p>Return the sub-string.</p>
6682
   */
6683
  public static function substr_left($haystack, $needle)
6684
  {
6685
    // init
6686
    $haystack = (string)$haystack;
6687
    $needle = (string)$needle;
6688
6689
    if (!isset($haystack[0])) {
6690
      return '';
6691
    }
6692
6693
    if (!isset($needle[0])) {
6694
      return $haystack;
6695
    }
6696
6697
    if (self::str_starts_with($haystack, $needle) === true) {
6698
      $haystackTmp = self::substr($haystack, self::strlen($needle));
6699
      if ($haystackTmp === false) {
6700
        $haystackTmp = '';
6701
      }
6702
      $haystack = (string)$haystackTmp;
6703
    }
6704
6705
    return $haystack;
6706
  }
6707
6708
  /**
6709
   * Replace text within a portion of a string.
@@ 6818-6840 (lines=23) @@
6815
   *
6816
   * @return string <p>Return the sub-string.</p>
6817
   */
6818
  public static function substr_right($haystack, $needle)
6819
  {
6820
    $haystack = (string)$haystack;
6821
    $needle = (string)$needle;
6822
6823
    if (!isset($haystack[0])) {
6824
      return '';
6825
    }
6826
6827
    if (!isset($needle[0])) {
6828
      return $haystack;
6829
    }
6830
6831
    if (self::str_ends_with($haystack, $needle) === true) {
6832
      $haystackTmp = self::substr($haystack, 0, self::strlen($haystack) - self::strlen($needle));
6833
      if ($haystackTmp === false) {
6834
        $haystackTmp = '';
6835
      }
6836
      $haystack = (string)$haystackTmp;
6837
    }
6838
6839
    return $haystack;
6840
  }
6841
6842
  /**
6843
   * Returns a case swapped version of the string.