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

QueryFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 29
ccs 9
cts 9
cp 1
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 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