Completed
Push — master ( 3b2851...0c6a37 )
by Marcin
02:12
created

Query   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 37
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A get() 0 11 2
1
<?php
2
3
namespace Mnabialek\LaravelSqlLogger;
4
5
use Mnabialek\LaravelSqlLogger\Objects\SqlQuery;
6
use Mnabialek\LaravelVersion\Version;
7
8
class Query
9
{
10
    /**
11
     * @var Version
12
     */
13
    private $version;
14
15
    /**
16
     * Query constructor.
17
     *
18
     * @param Version $version
19
     */
20
    public function __construct(Version $version)
21
    {
22
        $this->version = $version;
23
    }
24
25
    /**
26
     * @param int $number
27
     * @param string|\Illuminate\Database\Events\QueryExecuted $query
28
     * @param array|null $bindings
29
     * @param float|null $time
30
     *
31
     * @return SqlQuery
32
     */
33
    public function get($number, $query, array $bindings = null, $time = null)
34
    {
35
        // for Laravel/Lumen 5.2+ $query is object and it holds all the data
36
        if ($this->version->min('5.2.0')) {
37
            $bindings = $query->bindings;
38
            $time = $query->time;
39
            $query = $query->sql;
40
        }
41
42
        return new SqlQuery($number, $query, $bindings, $time);
43
    }
44
}
45