Completed
Pull Request — master (#919)
by Asmir
02:24
created

Query::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
c 1
b 0
f 0
nc 2
nop 3
dl 0
loc 9
ccs 6
cts 6
cp 1
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Migrations\Query;
6
7
use Doctrine\Migrations\Query\Exception\InvalidArguments;
8
use function count;
9
10
/**
11
 * The Query wraps the sql query, parameters and types.
12
 */
13
final class Query
14
{
15
    /** @var string */
16
    private $statement;
17
18
    /** @var mixed[] */
19
    private $parameters;
20
21
    /** @var mixed[] */
22
    private $types;
23
24
    /**
25
     * @param mixed[] $parameters
26
     * @param mixed[] $types
27
     */
28 28
    public function __construct(string $statement, array $parameters = [], array $types = [])
29
    {
30 28
        if (count($types) > count($parameters)) {
31 1
            throw InvalidArguments::wrongTypesArgumentCount($statement, count($parameters), count($types));
32
        }
33
34 27
        $this->statement  = $statement;
35 27
        $this->parameters = $parameters;
36 27
        $this->types      = $types;
37 27
    }
38
39 3
    public function __toString() : string
40
    {
41 3
        return $this->statement;
42
    }
43
44 13
    public function getStatement() : string
45
    {
46 13
        return $this->statement;
47
    }
48
49
    /** @return mixed[] */
50 12
    public function getParameters() : array
51
    {
52 12
        return $this->parameters;
53
    }
54
55
    /** @return mixed[] */
56 12
    public function getTypes() : array
57
    {
58 12
        return $this->types;
59
    }
60
}
61