Code Duplication    Length = 20-20 lines in 2 locations

modules/search/class.jetpack-search.php 1 location

@@ 480-499 (lines=20) @@
477
		 */
478
		do_action( 'did_jetpack_search_query', $query );
479
480
		if ( ! $response_code || $response_code < 200 || $response_code >= 300 ) {
481
			/**
482
			 * Fires after a search query request has failed
483
			 *
484
			 * @module search
485
			 *
486
			 * @since  5.6.0
487
			 *
488
			 * @param array Array containing the response code and response from the failed search query
489
			 */
490
			do_action(
491
				'failed_jetpack_search_query',
492
				array(
493
					'response_code' => $response_code,
494
					'json'          => $response,
495
				)
496
			);
497
498
			return new WP_Error( 'invalid_search_api_response', 'Invalid response from API - ' . $response_code );
499
		}
500
501
		return $response;
502
	}

modules/search/class-jetpack-instant-search.php 1 location

@@ 292-311 (lines=20) @@
289
		$response_code = wp_remote_retrieve_response_code( $request );
290
		$response      = json_decode( wp_remote_retrieve_body( $request ), true );
291
292
		if ( ! $response_code || $response_code < 200 || $response_code >= 300 ) {
293
			/**
294
			 * Fires after a search query request has failed
295
			 *
296
			 * @module search
297
			 *
298
			 * @since  5.6.0
299
			 *
300
			 * @param array Array containing the response code and response from the failed search query
301
			 */
302
			do_action(
303
				'failed_jetpack_search_query',
304
				array(
305
					'response_code' => $response_code,
306
					'json'          => $response,
307
				)
308
			);
309
310
			return new WP_Error( 'invalid_search_api_response', 'Invalid response from API - ' . $response_code );
311
		}
312
313
		$took = is_array( $response ) && ! empty( $response['took'] )
314
			? $response['took']