Code Duplication    Length = 13-16 lines in 2 locations

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

@@ 1133-1145 (lines=13) @@
1130
	 *
1131
	 * @return bool|WP_Error True if Jetpack successfully disconnected.
1132
	 */
1133
	public static function disconnect_site( $request ) {
1134
1135
		if ( ! isset( $request['isActive'] ) || $request['isActive'] !== false ) {
1136
			return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) );
1137
		}
1138
1139
		if ( Jetpack::is_active() ) {
1140
			Jetpack::disconnect();
1141
			return rest_ensure_response( array( 'code' => 'success' ) );
1142
		}
1143
1144
		return new WP_Error( 'disconnect_failed', esc_html__( 'Was not able to disconnect the site.  Please try again.', 'jetpack' ), array( 'status' => 400 ) );
1145
	}
1146
1147
	/**
1148
	 * Registers the Jetpack site
@@ 1299-1314 (lines=16) @@
1296
	 *
1297
	 * @return bool|WP_Error True if user successfully unlinked.
1298
	 */
1299
	public static function unlink_user( $request ) {
1300
1301
		if ( ! isset( $request['linked'] ) || $request['linked'] !== false ) {
1302
			return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) );
1303
		}
1304
1305
		if ( Connection_Manager::disconnect_user() ) {
1306
			return rest_ensure_response(
1307
				array(
1308
					'code' => 'success'
1309
				)
1310
			);
1311
		}
1312
1313
		return new WP_Error( 'unlink_user_failed', esc_html__( 'Was not able to unlink the user.  Please try again.', 'jetpack' ), array( 'status' => 400 ) );
1314
	}
1315
1316
	/**
1317
	 * Gets current user's tracking settings.