Code Duplication    Length = 53-53 lines in 2 locations

src/wp-includes/SimplePie/Misc.php 1 location

@@ 1769-1821 (lines=53) @@
1766
	 * @param string $data Data to strip comments from
1767
	 * @return string Comment stripped string
1768
	 */
1769
	public static function uncomment_rfc822($string)
1770
	{
1771
		$string = (string) $string;
1772
		$position = 0;
1773
		$length = strlen($string);
1774
		$depth = 0;
1775
1776
		$output = '';
1777
1778
		while ($position < $length && ($pos = strpos($string, '(', $position)) !== false)
1779
		{
1780
			$output .= substr($string, $position, $pos - $position);
1781
			$position = $pos + 1;
1782
			if ($string[$pos - 1] !== '\\')
1783
			{
1784
				$depth++;
1785
				while ($depth && $position < $length)
1786
				{
1787
					$position += strcspn($string, '()', $position);
1788
					if ($string[$position - 1] === '\\')
1789
					{
1790
						$position++;
1791
						continue;
1792
					}
1793
					elseif (isset($string[$position]))
1794
					{
1795
						switch ($string[$position])
1796
						{
1797
							case '(':
1798
								$depth++;
1799
								break;
1800
1801
							case ')':
1802
								$depth--;
1803
								break;
1804
						}
1805
						$position++;
1806
					}
1807
					else
1808
					{
1809
						break;
1810
					}
1811
				}
1812
			}
1813
			else
1814
			{
1815
				$output .= '(';
1816
			}
1817
		}
1818
		$output .= substr($string, $position);
1819
1820
		return $output;
1821
	}
1822
1823
	public static function parse_mime($mime)
1824
	{

src/wp-includes/SimplePie/Parse/Date.php 1 location

@@ 711-763 (lines=53) @@
708
	 * @param string $data Data to strip comments from
709
	 * @return string Comment stripped string
710
	 */
711
	public function remove_rfc2822_comments($string)
712
	{
713
		$string = (string) $string;
714
		$position = 0;
715
		$length = strlen($string);
716
		$depth = 0;
717
718
		$output = '';
719
720
		while ($position < $length && ($pos = strpos($string, '(', $position)) !== false)
721
		{
722
			$output .= substr($string, $position, $pos - $position);
723
			$position = $pos + 1;
724
			if ($string[$pos - 1] !== '\\')
725
			{
726
				$depth++;
727
				while ($depth && $position < $length)
728
				{
729
					$position += strcspn($string, '()', $position);
730
					if ($string[$position - 1] === '\\')
731
					{
732
						$position++;
733
						continue;
734
					}
735
					elseif (isset($string[$position]))
736
					{
737
						switch ($string[$position])
738
						{
739
							case '(':
740
								$depth++;
741
								break;
742
743
							case ')':
744
								$depth--;
745
								break;
746
						}
747
						$position++;
748
					}
749
					else
750
					{
751
						break;
752
					}
753
				}
754
			}
755
			else
756
			{
757
				$output .= '(';
758
			}
759
		}
760
		$output .= substr($string, $position);
761
762
		return $output;
763
	}
764
765
	/**
766
	 * Parse RFC2822's date format