Conditions | 5 |
Paths | 12 |
Total Lines | 19 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
31 | public function safeRun(string $action): bool |
||
32 | { |
||
33 | $this->dbInstance->begin(); |
||
34 | try { |
||
35 | switch ($action) { |
||
36 | default: |
||
37 | case 'up': |
||
38 | $result = $this->up(); |
||
39 | break; |
||
40 | case 'down': |
||
41 | $result = $this->down(); |
||
42 | break; |
||
43 | } |
||
44 | $result ? $this->dbInstance->commit() : $this->dbInstance->rollback(); |
||
45 | return $result; |
||
46 | } catch (\Exception $e) { |
||
47 | echo $e->getMessage() . PHP_EOL; |
||
48 | $this->dbInstance->rollback(); |
||
49 | return false; |
||
50 | } |
||
70 | } |