| Conditions | 3 |
| Paths | 4 |
| Total Lines | 15 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 44 | public function executeAtomically(callable $operation) |
||
| 45 | { |
||
| 46 | $this->pdo->beginTransaction(); |
||
| 47 | $this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); |
||
| 48 | |||
| 49 | try { |
||
| 50 | $return = call_user_func($operation, $this); |
||
| 51 | $this->pdo->commit(); |
||
| 52 | |||
| 53 | return $return ?: true; |
||
| 54 | } catch (\Exception $exception) { |
||
| 55 | $this->pdo->rollback(); |
||
| 56 | throw $exception; |
||
| 57 | } |
||
| 58 | } |
||
| 59 | } |
||
| 60 |