Code Duplication    Length = 13-16 lines in 2 locations

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

@@ 1096-1108 (lines=13) @@
1093
	 *
1094
	 * @return bool|WP_Error True if Jetpack successfully disconnected.
1095
	 */
1096
	public static function disconnect_site( $request ) {
1097
1098
		if ( ! isset( $request['isActive'] ) || $request['isActive'] !== false ) {
1099
			return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) );
1100
		}
1101
1102
		if ( Jetpack::is_active() ) {
1103
			Jetpack::disconnect();
1104
			return rest_ensure_response( array( 'code' => 'success' ) );
1105
		}
1106
1107
		return new WP_Error( 'disconnect_failed', esc_html__( 'Was not able to disconnect the site.  Please try again.', 'jetpack' ), array( 'status' => 400 ) );
1108
	}
1109
1110
	/**
1111
	 * Gets a new connect raw URL with fresh nonce.
@@ 1229-1244 (lines=16) @@
1226
	 *
1227
	 * @return bool|WP_Error True if user successfully unlinked.
1228
	 */
1229
	public static function unlink_user( $request ) {
1230
1231
		if ( ! isset( $request['linked'] ) || $request['linked'] !== false ) {
1232
			return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) );
1233
		}
1234
1235
		if ( Jetpack::unlink_user() ) {
1236
			return rest_ensure_response(
1237
				array(
1238
					'code' => 'success'
1239
				)
1240
			);
1241
		}
1242
1243
		return new WP_Error( 'unlink_user_failed', esc_html__( 'Was not able to unlink the user.  Please try again.', 'jetpack' ), array( 'status' => 400 ) );
1244
	}
1245
1246
	/**
1247
	 * Gets current user's tracking settings.