Passed
Push — master ( b8a6d9...158a9b )
by Бабичев
15:07 queued 10s
created

DbService::transaction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 2
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Bavix\Wallet\Services;
4
5
use Closure;
6
use Illuminate\Database\ConnectionInterface;
7
use Illuminate\Database\Query\Expression;
8
use Illuminate\Support\Facades\DB;
9
10
/**
11
 * Class DbService
12
 * @package Bavix\Wallet\Services
13
 * @codeCoverageIgnore
14
 */
15
class DbService
16
{
17
18
    /**
19
     * @return ConnectionInterface
20
     */
21
    public function connection(): ConnectionInterface
22
    {
23
        return DB::connection(config('wallet.database.connection'));
24
    }
25
26
    /**
27
     * Execute a Closure within a transaction.
28
     *
29
     * @param Closure $callback
30
     * @param int $attempts
31
     * @return mixed
32
     *
33
     * @throws \Throwable
34
     */
35
    public function transaction(Closure $callback, $attempts = 1)
36
    {
37
        return $this->connection()->transaction($callback, $attempts);
38
    }
39
40
    /**
41
     * Get a new raw query expression.
42
     *
43
     * @param mixed $value
44
     * @return Expression
45
     */
46
    public function raw($value): Expression
47
    {
48
        return $this->connection()->raw($value);
49
    }
50
51
}
52