From 69bd8f8206b73cb763364a3b9384f417f8e08718 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Dorn?= Date: Fri, 21 Apr 2023 11:34:55 +0200 Subject: [PATCH] dont send a request when deleting zero rules --- src/RuleManager.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/RuleManager.php b/src/RuleManager.php index 803594c..7190574 100644 --- a/src/RuleManager.php +++ b/src/RuleManager.php @@ -29,12 +29,16 @@ public function deleteMany(Rule|string|array $id): TwitterResponse } /** @param string|string[]|Rule[] $ids */ - public function delete(Rule|string|array $ids): TwitterResponse + public function delete(Rule|string|array $ids): ?TwitterResponse { if (!is_array($ids)) { $ids = [$ids]; } + if (count($ids) == 0) { + return null; + } + $ids = array_filter( array_map(fn ($id) => $id instanceof Rule ? $id->id : $id, $ids) );