Code Duplication    Length = 16-16 lines in 2 locations

projects/packages/backup/src/class-rest-controller.php 2 locations

@@ 438-453 (lines=16) @@
435
	 * @param WP_REST_Request $request The request sent to the WP REST API.
436
	 * @return array
437
	 */
438
	public static function fetch_term_backup( $request ) {
439
		// Disable Sync as this is a read-only operation and triggered by sync activity.
440
		Sync_Actions::mark_sync_read_only();
441
442
		$term_id = $request['id'];
443
		$term    = get_term( $term_id );
444
445
		if ( empty( $term ) ) {
446
			return new WP_Error( 'term_not_found', __( 'Term not found', 'jetpack' ), array( 'status' => 404 ) );
447
		}
448
449
		return array(
450
			'term' => (array) $term,
451
			'meta' => get_term_meta( $term_id ),
452
		);
453
	}
454
455
	/**
456
	 * Fetch a backup of a user, along with all of its metadata.
@@ 464-479 (lines=16) @@
461
	 * @param WP_REST_Request $request The request sent to the WP REST API.
462
	 * @return array
463
	 */
464
	public static function fetch_user_backup( $request ) {
465
		// Disable Sync as this is a read-only operation and triggered by sync activity.
466
		Sync_Actions::mark_sync_read_only();
467
468
		$user_id = $request['id'];
469
		$user    = get_user_by( 'id', $user_id );
470
471
		if ( empty( $user ) ) {
472
			return new WP_Error( 'user_not_found', __( 'User not found', 'jetpack' ), array( 'status' => 404 ) );
473
		}
474
475
		return array(
476
			'user' => $user->to_array(),
477
			'meta' => get_user_meta( $user->ID ),
478
		);
479
	}
480
481
	/**
482
	 * Get allowed object types for the '/database-object/backup' endpoint.