| Conditions | 4 |
| Paths | 4 |
| Total Lines | 19 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 0 | ||
| 1 | <?php |
||
| 35 | public function call(callable $callable, ...$args) |
||
| 36 | { |
||
| 37 | if ($this->connection->transaction && $this->connection->transaction->isActive) { |
||
| 38 | return call_user_func_array($callable, $args); |
||
| 39 | } |
||
| 40 | |||
| 41 | $transaction = $this->connection->beginTransaction(); |
||
| 42 | try { |
||
| 43 | $result = call_user_func_array($callable, $args); |
||
| 44 | |||
| 45 | $transaction->commit(); |
||
| 46 | |||
| 47 | return $result; |
||
| 48 | } catch (\Throwable $exception) { |
||
| 49 | $transaction->rollBack(); |
||
| 50 | |||
| 51 | throw $exception; |
||
| 52 | } |
||
| 53 | } |
||
| 54 | } |