From fcb9d0396693cfeaa7ea5f2799914dec18b007b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Fri, 26 Aug 2022 07:16:54 +0000 Subject: [PATCH 1/2] Add ToggleStrategies::isEmpty --- src/Read/ToggleStrategies.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Read/ToggleStrategies.php b/src/Read/ToggleStrategies.php index 706498b..4db126a 100644 --- a/src/Read/ToggleStrategies.php +++ b/src/Read/ToggleStrategies.php @@ -30,6 +30,11 @@ public function count(): int return count($this->strategies); } + public function isEmpty(): bool + { + return $this->strategies === []; + } + /** @return Generator */ public function getIterator(): Generator { From 397d0099b8e30c624df0bf232552a8709c53894f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Fri, 26 Aug 2022 07:18:18 +0000 Subject: [PATCH 2/2] Remove literal zeroo from Toggle --- src/Read/Toggle.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Read/Toggle.php b/src/Read/Toggle.php index 2cb6802..d4b83aa 100644 --- a/src/Read/Toggle.php +++ b/src/Read/Toggle.php @@ -6,7 +6,6 @@ final class Toggle { - private const ZERO = 0; private FeatureFinder $featureFinder; public function __construct(FeatureFinder $featureRepository) @@ -24,7 +23,7 @@ public function isEnabled(string $featureId, ?ConsumerIdentity $identity = null) $strategies = $feature->strategies(); - if (self::ZERO === $strategies->count() || null === $identity) { + if ($strategies->isEmpty() || null === $identity) { return true; }