Total Complexity | 4 |
Total Lines | 37 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
14 | class DbService |
||
15 | { |
||
16 | /** |
||
17 | * @return ConnectionInterface |
||
18 | */ |
||
19 | public function connection(): ConnectionInterface |
||
22 | } |
||
23 | |||
24 | /** |
||
25 | * Execute a Closure within a transaction. |
||
26 | * |
||
27 | * @param Closure $callback |
||
28 | * @param int $attempts |
||
29 | * @return mixed |
||
30 | * |
||
31 | * @throws \Throwable |
||
32 | */ |
||
33 | public function transaction(Closure $callback, $attempts = 1) |
||
34 | { |
||
35 | if ($this->connection()->transactionLevel()) { |
||
36 | return $callback($this); |
||
37 | } |
||
38 | |||
39 | return $this->connection()->transaction($callback, $attempts); |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * Get a new raw query expression. |
||
44 | * |
||
45 | * @param mixed $value |
||
46 | * @return Expression |
||
47 | */ |
||
48 | public function raw($value): Expression |
||
51 | } |
||
52 | } |
||
53 |