Code Duplication    Length = 13-16 lines in 2 locations

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

@@ 1183-1195 (lines=13) @@
1180
	 *
1181
	 * @return bool|WP_Error True if Jetpack successfully disconnected.
1182
	 */
1183
	public static function disconnect_site( $request ) {
1184
1185
		if ( ! isset( $request['isActive'] ) || $request['isActive'] !== false ) {
1186
			return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) );
1187
		}
1188
1189
		if ( Jetpack::is_active() ) {
1190
			Jetpack::disconnect();
1191
			return rest_ensure_response( array( 'code' => 'success' ) );
1192
		}
1193
1194
		return new WP_Error( 'disconnect_failed', esc_html__( 'Was not able to disconnect the site.  Please try again.', 'jetpack' ), array( 'status' => 400 ) );
1195
	}
1196
1197
	/**
1198
	 * Registers the Jetpack site
@@ 1349-1364 (lines=16) @@
1346
	 *
1347
	 * @return bool|WP_Error True if user successfully unlinked.
1348
	 */
1349
	public static function unlink_user( $request ) {
1350
1351
		if ( ! isset( $request['linked'] ) || $request['linked'] !== false ) {
1352
			return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) );
1353
		}
1354
1355
		if ( Connection_Manager::disconnect_user() ) {
1356
			return rest_ensure_response(
1357
				array(
1358
					'code' => 'success'
1359
				)
1360
			);
1361
		}
1362
1363
		return new WP_Error( 'unlink_user_failed', esc_html__( 'Was not able to unlink the user.  Please try again.', 'jetpack' ), array( 'status' => 400 ) );
1364
	}
1365
1366
	/**
1367
	 * Gets current user's tracking settings.