Code Duplication    Length = 7-11 lines in 2 locations

_inc/class.jetpack-provision.php 2 locations

@@ 204-214 (lines=11) @@
201
		$response_code = wp_remote_retrieve_response_code( $result );
202
		$body_json     = json_decode( wp_remote_retrieve_body( $result ) );
203
204
		if ( 200 !== $response_code ) {
205
			if ( isset( $body_json->error ) ) {
206
				return new WP_Error( $body_json->error, $body_json->message );
207
			} else {
208
				return new WP_Error(
209
					'server_error',
210
					/* translators: %s is an HTTP status code retured from an API request. Ex. – 400 */
211
					sprintf( __( 'Request failed with code %s', 'jetpack' ), $response_code )
212
				);
213
			}
214
		}
215
216
		if ( isset( $body_json->access_token ) && is_user_logged_in() ) {
217
			// Check if this matches the existing token before replacing.
@@ 271-277 (lines=7) @@
268
		$response_code = wp_remote_retrieve_response_code( $result );
269
		$body_json     = json_decode( wp_remote_retrieve_body( $result ) );
270
271
		if( 200 !== $response_code ) {
272
			if ( isset( $body_json->error ) ) {
273
				return new WP_Error( $body_json->error, $body_json->message );
274
			} else {
275
				return new WP_Error( 'server_error', sprintf( __( 'Request failed with code %s', 'jetpack' ), $response_code ) );
276
			}
277
		}
278
279
		return true;
280
	}