| Conditions | 4 | 
| Paths | 5 | 
| Total Lines | 21 | 
| Code Lines | 12 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
| 1 | <?php | ||
| 45 | public function transactional($func) | ||
| 46 |     { | ||
| 47 |         if (!is_callable($func)) { | ||
| 48 |             throw new \InvalidArgumentException('Expected argument of type "callable", got "' . gettype($func) . '"'); | ||
| 49 | } | ||
| 50 | |||
| 51 | $this->beginTransaction(); | ||
| 52 | |||
| 53 |         try { | ||
| 54 | $return = call_user_func($func, $this); | ||
| 55 | |||
| 56 | $this->commitTransaction(); | ||
| 57 | |||
| 58 | return $return ?: true; | ||
| 59 |         } catch (\Exception $e) { | ||
| 60 | $this->entityManager->close(); | ||
| 61 | $this->rollbackTransaction(); | ||
| 62 | |||
| 63 | throw $e; | ||
| 64 | } | ||
| 65 | } | ||
| 66 | } | ||
| 67 |