Skip to content

Commit 733f278

Browse files
exaby73transistive
authored andcommitted
refactor: Convert switch to if statements
1 parent bbab736 commit 733f278

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/Bolt/BoltUnmanagedTransaction.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,16 @@ public function commit(iterable $statements = []): CypherList
9898
public function rollback(): void
9999
{
100100
if ($this->isFinished()) {
101-
switch ($this->state) {
102-
case TransactionState::TERMINATED:
103-
throw new ClientException("Can't rollback, transaction has been terminated");
104-
case TransactionState::COMMITTED:
105-
throw new ClientException("Can't rollback, transaction has already been committed");
106-
case TransactionState::ROLLED_BACK:
107-
throw new ClientException("Can't rollback, transaction has already been rolled back");
108-
default:
101+
if ($this->state === TransactionState::TERMINATED) {
102+
throw new ClientException("Can't rollback, transaction has been terminated");
103+
}
104+
105+
if ($this->state === TransactionState::COMMITTED) {
106+
throw new ClientException("Can't rollback, transaction has already been committed");
107+
}
108+
109+
if ($this->state === TransactionState::ROLLED_BACK) {
110+
throw new ClientException("Can't rollback, transaction has already been rolled back");
109111
}
110112
}
111113

0 commit comments

Comments
 (0)