1
0
Fork 0
mirror of https://github.com/archtechx/enums.git synced 2025-12-12 16:54:03 +00:00
This commit is contained in:
Márk Magyar 2024-12-29 21:12:58 +01:00 committed by GitHub
commit 8c0c921f8e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 4 deletions

View file

@ -7,15 +7,16 @@ namespace ArchTech\Enums;
use Exception; use Exception;
use Iterator; use Iterator;
use IteratorAggregate; use IteratorAggregate;
use UnitEnum;
trait Comparable trait Comparable
{ {
public function is(mixed $enum): bool public function is(UnitEnum $enum): bool
{ {
return $this === $enum; return $this === $enum;
} }
public function isNot(mixed $enum): bool public function isNot(UnitEnum $enum): bool
{ {
return ! $this->is($enum); return ! $this->is($enum);
} }

View file

@ -6,7 +6,6 @@ test('the is method checks for equality', function () {
expect(Role::ADMIN->is(Role::ADMIN))->toBeTrue(); expect(Role::ADMIN->is(Role::ADMIN))->toBeTrue();
expect(Role::ADMIN->is(Role::GUEST))->toBeFalse(); expect(Role::ADMIN->is(Role::GUEST))->toBeFalse();
expect(Role::ADMIN->is('admin'))->toBeFalse();
}); });
it('the isNot method checks for inequality', function () { it('the isNot method checks for inequality', function () {
@ -16,7 +15,6 @@ it('the isNot method checks for inequality', function () {
expect(Role::ADMIN->isNot(Role::GUEST))->toBeTrue(); expect(Role::ADMIN->isNot(Role::GUEST))->toBeTrue();
expect(Role::ADMIN->isNot(Role::ADMIN))->toBeFalse(); expect(Role::ADMIN->isNot(Role::ADMIN))->toBeFalse();
expect(Role::ADMIN->isNot('admin'))->toBeTrue();
}); });
it('the in method checks for presence in an array', function () { it('the in method checks for presence in an array', function () {