Completed
Push — master ( be00fa...152a7c )
by Beniamin
05:51 queued 02:08
created

QueryFactory::buildQuery()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 3
crap 2
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\Query;
13
14
use Phuria\SQLBuilder\Connection\ConnectionInterface;
15
use Phuria\SQLBuilder\Connection\ConnectionManagerInterface;
16
use Phuria\SQLBuilder\Parameter\ParameterManagerInterface;
17
18
/**
19
 * @author Beniamin Jonatan Šimko <[email protected]>
20
 */
21
class QueryFactory implements QueryFactoryInterface
22
{
23
    /**
24
     * @var ConnectionManagerInterface
25
     */
26
    private $connectionManager;
27
28
    /**
29
     * @param ConnectionManagerInterface $connectionManager
30
     */
31 6
    public function __construct(ConnectionManagerInterface $connectionManager)
32
    {
33 6
        $this->connectionManager = $connectionManager;
34 6
    }
35
36
    /**
37
     * @inheritdoc
38
     */
39 2
    public function buildQuery($SQL, ParameterManagerInterface $parameterManager, $connectionHint = null)
40
    {
41 2
        if ($connectionHint instanceof ConnectionInterface) {
42 1
            $connection = $connectionHint;
43 1
        } else {
44 1
            $connection = $this->connectionManager->getConnection($connectionHint);
45
        }
46
47 2
        return new Query($SQL, $parameterManager, $connection);
48
    }
49
}
50