From 71d0b03fcda3eb33f594e7c9269a36c6b25b958e Mon Sep 17 00:00:00 2001 From: Tom Schlick Date: Sun, 4 May 2025 19:11:11 -0400 Subject: [PATCH 1/3] add isNotAny() --- src/EnumHelpers.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/EnumHelpers.php b/src/EnumHelpers.php index 1bbc0df..510c916 100644 --- a/src/EnumHelpers.php +++ b/src/EnumHelpers.php @@ -83,6 +83,11 @@ public function isNot(self $input): bool return ! $this->is($input); } + public function isNotAny(iterable $input): bool + { + return ! $this->isAny($input); + } + public static function fromValue(int|string|self $value): static { if ($value instanceof self) { From 2ac62257be283f6f1f0f886d72ff1bb414ca5a40 Mon Sep 17 00:00:00 2001 From: tomschlick Date: Sun, 4 May 2025 23:11:31 +0000 Subject: [PATCH 2/3] Fix styling --- tests/TestCase.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/TestCase.php b/tests/TestCase.php index 2f219c9..41a7825 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -14,7 +14,5 @@ protected function getPackageProviders($app): array ]; } - public function getEnvironmentSetUp($app) - { - } + public function getEnvironmentSetUp($app) {} } From 0d0ee386fcef49211f393692c89d527b3cf0f241 Mon Sep 17 00:00:00 2001 From: Tom Schlick Date: Sun, 4 May 2025 19:13:07 -0400 Subject: [PATCH 3/3] Update LaravelEnumsTest.php --- tests/LaravelEnumsTest.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/LaravelEnumsTest.php b/tests/LaravelEnumsTest.php index 3398793..c4d27f5 100644 --- a/tests/LaravelEnumsTest.php +++ b/tests/LaravelEnumsTest.php @@ -91,6 +91,11 @@ $this->assertFalse(IntEnum::ONE->isAny([IntEnum::TWO, IntEnum::THREE])); }); +test('an enum can check if it is not any of a list of enums', function () { + $this->assertFalse(IntEnum::ONE->isNotAny([IntEnum::ONE, IntEnum::TWO])); + $this->assertTrue(IntEnum::ONE->isNotAny([IntEnum::TWO, IntEnum::THREE])); +}); + test('an enum can be created from a value', function () { $this->assertEquals(IntEnum::ONE, IntEnum::fromValue(1)); });