Completed
Push — master ( fd0133...375486 )
by Beniamin
02:35
created

QueryFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 77.78%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 29
ccs 7
cts 9
cp 0.7778
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A buildQuery() 0 10 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 5
    public function __construct(ConnectionManagerInterface $connectionManager)
32
    {
33 5
        $this->connectionManager = $connectionManager;
34 5
    }
35
36
    /**
37
     * @inheritdoc
38
     */
39 1
    public function buildQuery($SQL, ParameterManagerInterface $parameterManager, $connectionHint = null)
40
    {
41 1
        if ($connectionHint instanceof ConnectionInterface) {
42
            $connection = $connectionHint;
43
        } else {
44 1
            $connection = $this->connectionManager->getConnection($connectionHint);
45
        }
46
47 1
        return new Query($SQL, $parameterManager, $connection);
48
    }
49
}
50