Completed
Push — master ( 7aa5ea...c891e1 )
by Beniamin
08:55
created

Query   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 72.72%

Importance

Changes 0
Metric Value
dl 0
loc 51
c 0
b 0
f 0
wmc 4
lcom 1
cbo 3
ccs 8
cts 11
cp 0.7272
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getSQL() 0 4 1
A getParameters() 0 4 1
A setParameter() 0 6 1
1
<?php
2
3
/**
4
 * This file is part of UnderQuery 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\UnderQuery\Query;
13
14
use Phuria\UnderQuery\Parameter\ParameterCollection;
15
use Phuria\UnderQuery\Parameter\ParameterCollectionInterface;
16
17
/**
18
 * @author Beniamin Jonatan Šimko <[email protected]>
19
 */
20
class Query
21
{
22
    /**
23
     * @var string
24
     */
25
    private $sql;
26
27
    /**
28
     * @var ParameterCollectionInterface
29
     */
30
    private $parameterCollection;
31
32
    /**
33
     * @param string $sql
34
     * @param array  $parameters
35
     */
36 2
    public function __construct($sql, array $parameters = [])
37
    {
38 2
        $this->sql = $sql;
39 2
        $this->parameterCollection = new ParameterCollection($parameters);
40 2
    }
41
42
    /**
43
     * @return string
44
     */
45 1
    public function getSQL()
46
    {
47 1
        return $this->sql;
48
    }
49
50
    /**
51
     * @return ParameterCollectionInterface
52
     */
53 1
    public function getParameters()
54
    {
55 1
        return $this->parameterCollection;
56
    }
57
58
    /**
59
     * @param int|string $name
60
     * @param mixed      $value
61
     *
62
     * @return $this
63
     */
64
    public function setParameter($name, $value)
65
    {
66
        $this->getParameters()->getParameter($name)->setValue($value);
67
68
        return $this;
69
    }
70
}