| Conditions | 5 |
| Paths | 6 |
| Total Lines | 25 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 31 | public function invoke(MethodInvocation $invocation) |
||
| 32 | { |
||
| 33 | $method = $invocation->getMethod(); |
||
| 34 | assert($method instanceof ReflectionMethod); |
||
| 35 | $transactional = $method->getAnnotation(Transactional::class); |
||
| 36 | assert($transactional instanceof Transactional); |
||
| 37 | if (is_array($transactional->value) && count((array) $transactional->value) > 1) { |
||
| 38 | return (new PropTransaction())($invocation, $transactional); |
||
|
|
|||
| 39 | } |
||
| 40 | |||
| 41 | if (! $this->pdo instanceof ExtendedPdoInterface) { |
||
| 42 | return $invocation->proceed(); |
||
| 43 | } |
||
| 44 | |||
| 45 | try { |
||
| 46 | $this->pdo->beginTransaction(); |
||
| 47 | $result = $invocation->proceed(); |
||
| 48 | $this->pdo->commit(); |
||
| 49 | } catch (PDOException $e) { |
||
| 50 | $this->pdo->rollBack(); |
||
| 51 | |||
| 52 | throw new RollbackException($e->getMessage(), 0, $e); |
||
| 53 | } |
||
| 54 | |||
| 55 | return $result; |
||
| 56 | } |
||
| 58 |