Code Duplication    Length = 26-27 lines in 2 locations

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

@@ 1304-1329 (lines=26) @@
1301
	 *
1302
	 * @return array Array of rewind properties.
1303
	 */
1304
	public static function get_rewind_data() {
1305
		$rewind_data = self::rewind_data();
1306
1307
		if ( ! is_wp_error( $rewind_data ) ) {
1308
			return rest_ensure_response( array(
1309
					'code' => 'success',
1310
					'message' => esc_html__( 'Backup & Scan data correctly received.', 'jetpack' ),
1311
					'data' => wp_json_encode( $rewind_data ),
1312
				)
1313
			);
1314
		}
1315
1316
		if ( $rewind_data->get_error_code() === 'rewind_data_fetch_failed' ) {
1317
			return new WP_Error( 'rewind_data_fetch_failed', esc_html__( 'Failed fetching rewind data. Try again later.', 'jetpack' ), array( 'status' => 400 ) );
1318
		}
1319
1320
		if ( $rewind_data->get_error_code() === 'site_id_missing' ) {
1321
			return new WP_Error( 'site_id_missing', esc_html__( 'The ID of this site does not exist.', 'jetpack' ), array( 'status' => 404 ) );
1322
		}
1323
1324
		return new WP_Error(
1325
			'error_get_rewind_data',
1326
			esc_html__( 'Could not retrieve Backup & Scan data.', 'jetpack' ),
1327
			array( 'status' => 500 )
1328
		);
1329
	}
1330
1331
	/**
1332
	 * Gets Scan state data.
@@ 1383-1409 (lines=27) @@
1380
	 *
1381
	 * @return WP_REST_Response|WP_Error REST response or error state.
1382
	 */
1383
	public static function get_scan_state() {
1384
		$scan_state = self::scan_state();
1385
1386
		if ( ! is_wp_error( $scan_state ) ) {
1387
			return rest_ensure_response(
1388
				array(
1389
					'code'    => 'success',
1390
					'message' => esc_html__( 'Scan state correctly received.', 'jetpack' ),
1391
					'data'    => wp_json_encode( $scan_state ),
1392
				)
1393
			);
1394
		}
1395
1396
		if ( $scan_state->get_error_code() === 'scan_state_fetch_failed' ) {
1397
			return new WP_Error( 'scan_state_fetch_failed', esc_html__( 'Failed fetching rewind data. Try again later.', 'jetpack' ), array( 'status' => 400 ) );
1398
		}
1399
1400
		if ( $scan_state->get_error_code() === 'site_id_missing' ) {
1401
			return new WP_Error( 'site_id_missing', esc_html__( 'The ID of this site does not exist.', 'jetpack' ), array( 'status' => 404 ) );
1402
		}
1403
1404
		return new WP_Error(
1405
			'error_get_rewind_data',
1406
			esc_html__( 'Could not retrieve Scan state.', 'jetpack' ),
1407
			array( 'status' => 500 )
1408
		);
1409
	}
1410
1411
	/**
1412
	 * Disconnects Jetpack from the WordPress.com Servers