| Conditions | 5 |
| Paths | 6 |
| Total Lines | 24 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 26 | #[Override] |
||
| 27 | public function invoke(MethodInvocation $invocation) |
||
| 28 | { |
||
| 29 | $method = $invocation->getMethod(); |
||
| 30 | $transactional = $method->getAnnotation(Transactional::class); |
||
| 31 | if ($transactional instanceof Transactional && count((array) $transactional->value) > 1) { |
||
| 32 | return (new PropTransaction())($invocation, $transactional); |
||
|
|
|||
| 33 | } |
||
| 34 | |||
| 35 | if (! $this->pdo instanceof ExtendedPdoInterface) { |
||
| 36 | return $invocation->proceed(); |
||
| 37 | } |
||
| 38 | |||
| 39 | try { |
||
| 40 | $this->pdo->beginTransaction(); |
||
| 41 | $result = $invocation->proceed(); |
||
| 42 | $this->pdo->commit(); |
||
| 43 | } catch (PDOException $e) { |
||
| 44 | $this->pdo->rollBack(); |
||
| 45 | |||
| 46 | throw new RollbackException($e->getMessage(), 0, $e); |
||
| 47 | } |
||
| 48 | |||
| 49 | return $result; |
||
| 50 | } |
||
| 52 |