mirror of
https://github.com/archtechx/enums.git
synced 2025-12-12 09:24:03 +00:00
Merge 2911c55b84 into 6a0399823f
This commit is contained in:
commit
8c0c921f8e
2 changed files with 3 additions and 4 deletions
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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 () {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue