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

Query::fetchScalar()   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
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 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
}