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