Code Duplication    Length = 4-6 lines in 4 locations

_inc/lib/jetpack-wpes-query-builder/jetpack-wpes-query-parser.php 4 locations

@@ 383-388 (lines=6) @@
380
		$args = wp_parse_args( $args, $defaults );
381
382
		$phrases = array();
383
		if ( preg_match_all( '/"([^"]+)"/', $this->current_query, $matches ) ) {
384
			foreach ( $matches[1] as $match ) {
385
				$phrases[] = $match;
386
			}
387
			$this->current_query = preg_replace( '/"([^"]+)"/', '', $this->current_query );
388
		}
389
390
		if ( preg_match_all( "/'([^']+)'/", $this->current_query, $matches ) ) {
391
			foreach ( $matches[1] as $match ) {
@@ 390-395 (lines=6) @@
387
			$this->current_query = preg_replace( '/"([^"]+)"/', '', $this->current_query );
388
		}
389
390
		if ( preg_match_all( "/'([^']+)'/", $this->current_query, $matches ) ) {
391
			foreach ( $matches[1] as $match ) {
392
				$phrases[] = $match;
393
			}
394
			$this->current_query = preg_replace( "/'([^']+)'/", '', $this->current_query );
395
		}
396
397
		//look for a final, uncompleted phrase
398
		$phrase_prefix = false;
@@ 399-402 (lines=4) @@
396
397
		//look for a final, uncompleted phrase
398
		$phrase_prefix = false;
399
		if ( preg_match_all( '/"([^"]+)$/', $this->current_query, $matches ) ) {
400
			$phrase_prefix = $matches[1][0];
401
			$this->current_query = preg_replace( '/"([^"]+)$/', '', $this->current_query );
402
		}
403
		if ( preg_match_all( "/(?:'\B|\B')([^']+)$/", $this->current_query, $matches ) ) {
404
			$phrase_prefix = $matches[1][0];
405
			$this->current_query = preg_replace( "/(?:'\B|\B')([^']+)$/", '', $this->current_query );
@@ 403-406 (lines=4) @@
400
			$phrase_prefix = $matches[1][0];
401
			$this->current_query = preg_replace( '/"([^"]+)$/', '', $this->current_query );
402
		}
403
		if ( preg_match_all( "/(?:'\B|\B')([^']+)$/", $this->current_query, $matches ) ) {
404
			$phrase_prefix = $matches[1][0];
405
			$this->current_query = preg_replace( "/(?:'\B|\B')([^']+)$/", '', $this->current_query );
406
		}
407
408
		if ( $phrase_prefix ) {
409
			$phrases[] = $phrase_prefix;