Code Duplication    Length = 7-11 lines in 2 locations

_inc/class.jetpack-provision.php 2 locations

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