Code Duplication    Length = 26-27 lines in 2 locations

_inc/lib/class.core-rest-api-endpoints.php 2 locations

@@ 1220-1245 (lines=26) @@
1217
	 *
1218
	 * @return array Array of rewind properties.
1219
	 */
1220
	public static function get_rewind_data() {
1221
		$rewind_data = self::rewind_data();
1222
1223
		if ( ! is_wp_error( $rewind_data ) ) {
1224
			return rest_ensure_response( array(
1225
					'code' => 'success',
1226
					'message' => esc_html__( 'Backup & Scan data correctly received.', 'jetpack' ),
1227
					'data' => wp_json_encode( $rewind_data ),
1228
				)
1229
			);
1230
		}
1231
1232
		if ( $rewind_data->get_error_code() === 'rewind_data_fetch_failed' ) {
1233
			return new WP_Error( 'rewind_data_fetch_failed', esc_html__( 'Failed fetching rewind data. Try again later.', 'jetpack' ), array( 'status' => 400 ) );
1234
		}
1235
1236
		if ( $rewind_data->get_error_code() === 'site_id_missing' ) {
1237
			return new WP_Error( 'site_id_missing', esc_html__( 'The ID of this site does not exist.', 'jetpack' ), array( 'status' => 404 ) );
1238
		}
1239
1240
		return new WP_Error(
1241
			'error_get_rewind_data',
1242
			esc_html__( 'Could not retrieve Backup & Scan data.', 'jetpack' ),
1243
			array( 'status' => 500 )
1244
		);
1245
	}
1246
1247
	/**
1248
	 * Gets Scan state data.
@@ 1279-1305 (lines=27) @@
1276
	 *
1277
	 * @return WP_REST_Response|WP_Error REST response or error state.
1278
	 */
1279
	public static function get_scan_state() {
1280
		$scan_state = self::scan_state();
1281
1282
		if ( ! is_wp_error( $scan_state ) ) {
1283
			return rest_ensure_response(
1284
				array(
1285
					'code'    => 'success',
1286
					'message' => esc_html__( 'Scan state correctly received.', 'jetpack' ),
1287
					'data'    => wp_json_encode( $scan_state ),
1288
				)
1289
			);
1290
		}
1291
1292
		if ( $scan_state->get_error_code() === 'scan_state_fetch_failed' ) {
1293
			return new WP_Error( 'scan_state_fetch_failed', esc_html__( 'Failed fetching rewind data. Try again later.', 'jetpack' ), array( 'status' => 400 ) );
1294
		}
1295
1296
		if ( $scan_state->get_error_code() === 'site_id_missing' ) {
1297
			return new WP_Error( 'site_id_missing', esc_html__( 'The ID of this site does not exist.', 'jetpack' ), array( 'status' => 404 ) );
1298
		}
1299
1300
		return new WP_Error(
1301
			'error_get_rewind_data',
1302
			esc_html__( 'Could not retrieve Scan state.', 'jetpack' ),
1303
			array( 'status' => 500 )
1304
		);
1305
	}
1306
1307
	/**
1308
	 * Disconnects Jetpack from the WordPress.com Servers