Code Duplication    Length = 7-11 lines in 2 locations

_inc/class.jetpack-provision.php 2 locations

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