1
0
Fork 0
mirror of https://github.com/archtechx/enums.git synced 2025-12-12 09:44:03 +00:00
enums/src/Comparable.php
2023-06-08 09:30:31 +07:00

28 lines
493 B
PHP

<?php
declare(strict_types=1);
namespace ArchTech\Enums;
trait Comparable
{
public function is(mixed $enum): bool
{
return $this === $enum;
}
public function isNot(mixed $enum): bool
{
return ! $this->is($enum);
}
public function in(array $enums): bool
{
return [] !== array_filter($enums, fn (mixed $enum) => $this->is($enum));
}
public function notIn(array $enums): bool
{
return ! $this->in($enums);
}
}