Skip to content

Commit bbab736

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

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
@@ -68,14 +68,16 @@ public function __construct(
6868
public function commit(iterable $statements = []): CypherList
6969
{
7070
if ($this->isFinished()) {
71-
switch ($this->state) {
72-
case TransactionState::TERMINATED:
73-
throw new ClientException("Can't commit, transaction has been terminated");
74-
case TransactionState::COMMITTED:
75-
throw new ClientException("Can't commit, transaction has already been committed");
76-
case TransactionState::ROLLED_BACK:
77-
throw new ClientException("Can't commit, transaction has already been rolled back");
78-
default:
71+
if ($this->state === TransactionState::TERMINATED) {
72+
throw new ClientException("Can't commit, transaction has been terminated");
73+
}
74+
75+
if ($this->state === TransactionState::COMMITTED) {
76+
throw new ClientException("Can't commit, transaction has already been committed");
77+
}
78+
79+
if ($this->state === TransactionState::ROLLED_BACK) {
80+
throw new ClientException("Can't commit, transaction has already been rolled back");
7981
}
8082
}
8183

0 commit comments

Comments
 (0)