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) { 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)); }); 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) {} }