Code Duplication    Length = 23-24 lines in 4 locations

src/voku/helper/UTF8.php 4 locations

@@ 6585-6608 (lines=24) @@
6582
   *
6583
   * @return string <p>Return the sub-string.</p>
6584
   */
6585
  public static function substr_ileft($haystack, $needle)
6586
  {
6587
    // init
6588
    $haystack = (string)$haystack;
6589
    $needle = (string)$needle;
6590
6591
    if (!isset($haystack[0])) {
6592
      return '';
6593
    }
6594
6595
    if (!isset($needle[0])) {
6596
      return $haystack;
6597
    }
6598
6599
    if (self::str_istarts_with($haystack, $needle) === true) {
6600
      $haystackTmp = self::substr($haystack, self::strlen($needle));
6601
      if ($haystackTmp === false) {
6602
        $haystackTmp = '';
6603
      }
6604
      $haystack = (string)$haystackTmp;
6605
    }
6606
6607
    return $haystack;
6608
  }
6609
6610
  /**
6611
   * Removes an suffix ($needle) from end of the string ($haystack), case insensitive.
@@ 6618-6641 (lines=24) @@
6615
   *
6616
   * @return string <p>Return the sub-string.</p>
6617
   */
6618
  public static function substr_iright($haystack, $needle)
6619
  {
6620
    // init
6621
    $haystack = (string)$haystack;
6622
    $needle = (string)$needle;
6623
6624
    if (!isset($haystack[0])) {
6625
      return '';
6626
    }
6627
6628
    if (!isset($needle[0])) {
6629
      return $haystack;
6630
    }
6631
6632
    if (self::str_iends_with($haystack, $needle) === true) {
6633
      $haystackTmp = self::substr($haystack, 0, self::strlen($haystack) - self::strlen($needle));
6634
      if ($haystackTmp === false) {
6635
        $haystackTmp = '';
6636
      }
6637
      $haystack = (string)$haystackTmp;
6638
    }
6639
6640
    return $haystack;
6641
  }
6642
6643
  /**
6644
   * Removes an prefix ($needle) from start of the string ($haystack).
@@ 6651-6674 (lines=24) @@
6648
   *
6649
   * @return string <p>Return the sub-string.</p>
6650
   */
6651
  public static function substr_left($haystack, $needle)
6652
  {
6653
    // init
6654
    $haystack = (string)$haystack;
6655
    $needle = (string)$needle;
6656
6657
    if (!isset($haystack[0])) {
6658
      return '';
6659
    }
6660
6661
    if (!isset($needle[0])) {
6662
      return $haystack;
6663
    }
6664
6665
    if (self::str_starts_with($haystack, $needle) === true) {
6666
      $haystackTmp = self::substr($haystack, self::strlen($needle));
6667
      if ($haystackTmp === false) {
6668
        $haystackTmp = '';
6669
      }
6670
      $haystack = (string)$haystackTmp;
6671
    }
6672
6673
    return $haystack;
6674
  }
6675
6676
  /**
6677
   * Replace text within a portion of a string.
@@ 6786-6808 (lines=23) @@
6783
   *
6784
   * @return string <p>Return the sub-string.</p>
6785
   */
6786
  public static function substr_right($haystack, $needle)
6787
  {
6788
    $haystack = (string)$haystack;
6789
    $needle = (string)$needle;
6790
6791
    if (!isset($haystack[0])) {
6792
      return '';
6793
    }
6794
6795
    if (!isset($needle[0])) {
6796
      return $haystack;
6797
    }
6798
6799
    if (self::str_ends_with($haystack, $needle) === true) {
6800
      $haystackTmp = self::substr($haystack, 0, self::strlen($haystack) - self::strlen($needle));
6801
      if ($haystackTmp === false) {
6802
        $haystackTmp = '';
6803
      }
6804
      $haystack = (string)$haystackTmp;
6805
    }
6806
6807
    return $haystack;
6808
  }
6809
6810
  /**
6811
   * Returns a case swapped version of the string.