From b9f33f36a3f5263911d8eb5f88c5f434c9612fb0 Mon Sep 17 00:00:00 2001 From: Thai Nguyen Hung Date: Thu, 8 Jun 2023 09:30:31 +0700 Subject: [PATCH] feat: comparable enum --- src/Comparable.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/Comparable.php diff --git a/src/Comparable.php b/src/Comparable.php new file mode 100644 index 0000000..d47de19 --- /dev/null +++ b/src/Comparable.php @@ -0,0 +1,28 @@ +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); + } +}