| Conditions | 3 |
| Paths | 3 |
| Total Lines | 18 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | 16 | protected function handleTransaction(callable $transaction) |
|
| 17 | { |
||
| 18 | 16 | $this->transacting = true; |
|
| 19 | try { |
||
| 20 | 16 | $result = $transaction(); |
|
| 21 | 12 | } catch (\Exception $e) { |
|
| 22 | 5 | $this->transacting = false; |
|
| 23 | // Catch any exceptions |
||
| 24 | 5 | throw new TransactionException('Transaction raised an exception: ' . $e->getMessage(), 500, $e); |
|
| 25 | 1 | } catch (\Throwable $e) { |
|
| 26 | 1 | $this->transacting = false; |
|
| 27 | // Catch extra stuff in PHP 7+ |
||
| 28 | 1 | throw new TransactionException('Transaction raised an exception: ' . $e->getMessage(), 500, $e); |
|
| 29 | } |
||
| 30 | 10 | $this->transacting = false; |
|
| 31 | |||
| 32 | 10 | return $result; |
|
| 33 | } |
||
| 34 | |||
| 48 |