| Total Complexity | 6 |
| Total Lines | 87 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 24 | abstract class TransactionalMigration extends Migration |
||
| 25 | { |
||
| 26 | /** |
||
| 27 | * @inheritDoc |
||
| 28 | * |
||
| 29 | * @throws Throwable |
||
| 30 | */ |
||
| 31 | #[Override] |
||
| 32 | public function run(): void |
||
| 33 | { |
||
| 34 | $orm = $this->orm; |
||
| 35 | |||
| 36 | try { |
||
| 37 | $orm->ensureTransaction(); |
||
| 38 | |||
| 39 | $this->runMigration(); |
||
| 40 | |||
| 41 | $orm->commit(); |
||
| 42 | } catch (Throwable $exception) { |
||
| 43 | $orm->rollback(); |
||
| 44 | |||
| 45 | $this->runFailure($exception); |
||
| 46 | |||
| 47 | throw $exception; |
||
| 48 | } |
||
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * @inheritDoc |
||
| 53 | * |
||
| 54 | * @throws Throwable |
||
| 55 | */ |
||
| 56 | #[Override] |
||
| 57 | public function rollback(): void |
||
| 58 | { |
||
| 59 | $orm = $this->orm; |
||
| 60 | |||
| 61 | try { |
||
| 62 | $orm->ensureTransaction(); |
||
| 63 | |||
| 64 | $this->rollbackMigration(); |
||
| 65 | |||
| 66 | $orm->commit(); |
||
| 67 | } catch (Throwable $exception) { |
||
| 68 | $orm->rollback(); |
||
| 69 | |||
| 70 | $this->rollbackFailure($exception); |
||
| 71 | |||
| 72 | throw $exception; |
||
| 73 | } |
||
| 74 | } |
||
| 75 | |||
| 76 | /** |
||
| 77 | * Do on run failure. |
||
| 78 | * |
||
| 79 | * @param Throwable $exception The exception |
||
| 80 | * |
||
| 81 | * @return void |
||
| 82 | */ |
||
| 83 | protected function runFailure(Throwable $exception): void |
||
| 84 | { |
||
| 85 | } |
||
| 86 | |||
| 87 | /** |
||
| 88 | * Do on rollback failure. |
||
| 89 | * |
||
| 90 | * @param Throwable $exception The exception |
||
| 91 | * |
||
| 92 | * @return void |
||
| 93 | */ |
||
| 94 | protected function rollbackFailure(Throwable $exception): void |
||
| 96 | } |
||
| 97 | |||
| 98 | /** |
||
| 99 | * Run the migration. |
||
| 100 | * |
||
| 101 | * @return void |
||
| 102 | */ |
||
| 103 | abstract protected function runMigration(): void; |
||
| 104 | |||
| 105 | /** |
||
| 106 | * Rollback the migration. |
||
| 107 | * |
||
| 108 | * @return void |
||
| 109 | */ |
||
| 110 | abstract protected function rollbackMigration(): void; |
||
| 111 | } |
||
| 112 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths