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

DbService   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 4
c 1
b 0
f 1
dl 0
loc 34
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A raw() 0 3 1
A transaction() 0 3 1
A connection() 0 3 1
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