| Total Complexity | 3 |
| Total Lines | 22 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | trait SafeActionTrait |
||
| 12 | { |
||
| 13 | public $enableTransaction = true; |
||
| 14 | |||
| 15 | public function run($id = null, callable $callback = null) |
||
| 16 | { |
||
| 17 | $run = $callback ?? [$this, 'parent::run']; |
||
| 18 | $args = array_filter([$id]); |
||
| 19 | |||
| 20 | if (!$this->enableTransaction) { |
||
| 21 | return call_user_func_array($run, $args); |
||
| 22 | } |
||
| 23 | |||
| 24 | return DbHelper::transaction($run, $args, $this->getDb()); |
||
| 25 | } |
||
| 26 | |||
| 27 | public function getDb(): Connection |
||
| 33 | } |
||
| 34 | } |
||
| 35 |