Completed
Push — master ( b54f87...bde51f )
by Beniamin
04:50
created

QueryComponentTrait::buildSQL()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
/**
4
 * This file is part of Phuria SQL Builder package.
5
 *
6
 * Copyright (c) 2016 Beniamin Jonatan Šimko
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Phuria\SQLBuilder\QueryBuilder\Component;
13
14
use Phuria\SQLBuilder\Connection\ConnectionInterface;
15
use Phuria\SQLBuilder\Parameter\ParameterManagerInterface;
16
use Phuria\SQLBuilder\Query;
17
use Phuria\SQLBuilder\QueryBuilder\AbstractBuilder;
18
use Phuria\SQLBuilder\QueryCompiler\QueryCompilerInterface;
19
20
/**
21
 * @author Beniamin Jonatan Šimko <[email protected]>
22
 */
23
trait QueryComponentTrait
24
{
25
    /**
26
     * @return AbstractBuilder
27
     */
28
    abstract public function getQueryBuilder();
29
30
    /**
31
     * @return QueryCompilerInterface
32
     */
33
    abstract public function getQueryCompiler();
34
35
    /**
36
     * @return ParameterManagerInterface
37
     */
38
    abstract public function getParameterManager();
39
40
    /**
41
     * @return string
42
     */
43 27
    public function buildSQL()
44
    {
45 27
        return $this->getQueryCompiler()->compile($this->getQueryBuilder());
46
    }
47
48
    /**
49
     * @param ConnectionInterface $connection
0 ignored issues
show
Documentation introduced by
Should the type for parameter $connection not be null|ConnectionInterface?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
50
     *
51
     * @return Query
52
     */
53 13
    public function buildQuery(ConnectionInterface $connection = null)
54
    {
55 13
        return new Query(
56 13
            $this->buildSQL(),
57 13
            $this->getParameterManager(),
58
            $connection
59 13
        );
60
    }
61
}