Code Duplication    Length = 13-16 lines in 2 locations

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

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