From dcbe6ff7124781381972dba9bce359451ae7af2c Mon Sep 17 00:00:00 2001 From: Aaron Piotrowski Date: Mon, 11 Apr 2022 22:27:36 -0500 Subject: [PATCH] TransactionIsolation helper methods --- src/TransactionIsolation.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/TransactionIsolation.php b/src/TransactionIsolation.php index 532101b..d00dab5 100644 --- a/src/TransactionIsolation.php +++ b/src/TransactionIsolation.php @@ -8,4 +8,24 @@ enum TransactionIsolation case Committed; case Repeatable; case Serializable; + + public function getLabel(): string + { + return match ($this) { + self::Uncommitted => 'Uncommitted', + self::Committed => 'Committed', + self::Repeatable => 'Repeatable', + self::Serializable => 'Serializable', + }; + } + + public function toSql(): string + { + return match ($this) { + self::Uncommitted => 'READ UNCOMMITTED', + self::Committed => 'READ COMMITTED', + self::Repeatable => 'REPEATABLE READ', + self::Serializable => 'SERIALIZABLE', + }; + } }