Code Duplication    Length = 6-6 lines in 3 locations

_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-external-media.php 3 locations

@@ 257-262 (lines=6) @@
254
		$params     = $request->get_params();
255
		$wpcom_path = sprintf( '/meta/external-media/%s', rawurlencode( $params['service'] ) );
256
257
		if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
258
			$request = new \WP_REST_Request( 'GET', '/' . $this->namespace . $wpcom_path );
259
			$request->set_query_params( $params );
260
261
			return rest_do_request( $request );
262
		}
263
264
		// Build query string to pass to wpcom endpoint.
265
		$service_args = array_filter(
@@ 358-363 (lines=6) @@
355
		$service    = rawurlencode( $request->get_param( 'service' ) );
356
		$wpcom_path = sprintf( '/meta/external-media/connection/%s', $service );
357
358
		if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
359
			$internal_request = new \WP_REST_Request( 'GET', '/' . $this->namespace . $wpcom_path );
360
			$internal_request->set_query_params( $request->get_params() );
361
362
			return rest_do_request( $internal_request );
363
		}
364
365
		$response = Client::wpcom_json_api_request_as_user( $wpcom_path );
366
@@ 380-385 (lines=6) @@
377
		$service    = rawurlencode( $request->get_param( 'service' ) );
378
		$wpcom_path = sprintf( '/meta/external-media/connection/%s', $service );
379
380
		if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
381
			$internal_request = new WP_REST_Request( REQUESTS::DELETE, '/' . $this->namespace . $wpcom_path );
382
			$internal_request->set_query_params( $request->get_params() );
383
384
			return rest_do_request( $internal_request );
385
		}
386
387
		$response = Client::wpcom_json_api_request_as_user(
388
			$wpcom_path,