Passed
Push — master ( b5bf25...b5ca6c )
by Aleksandar
02:13
created

RawQueryResult::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 3
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
/**
3
 * Copyright 2021 Aleksandar Panic
4
 *
5
 * Licensed under the Apache License, Version 2.0 (the "License");
6
 * you may not use this file except in compliance with the License.
7
 * You may obtain a copy of the License at
8
 *
9
 *   http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 */
17
18
namespace ArekX\PQL;
19
20
/**
21
 * Represents a high-level implementation for a
22
 * raw query  which can be used in a database driver.
23
 */
24
class RawQueryResult implements Contracts\RawQuery
25
{
26
    /**
27
     * Passed query.
28
     * @var mixed
29
     */
30
    protected $query = null;
31
32
    /**
33
     * Passed parameters
34
     * @var array|null
35
     */
36
    protected $params = null;
37
38
    /**
39
     * Passed configuration
40
     *
41
     * @var array|null
42
     */
43
    protected $config = null;
44
45
    /**
46
     * Create new instance of this class
47
     *
48
     * @param mixed $query Query to be used
49
     * @param array|null $params Parameters to be bound to the query
50
     * @param array|null $config Configuration to be bound to the query
51
     * @return static
52
     */
53 12
    public static function create($query, $params = null, $config = null)
54
    {
55 12
        return new static($query, $params, $config);
56
    }
57
58
    /**
59
     * Constructor for RawQuery
60
     *
61
     * @param mixed $query Query to be used
62
     * @param array|null $params Parameters to be bound to the query
63
     * @param array|null $config Configuration to be bound to the query
64
     */
65 12
    public function __construct($query, $params = null, $config = null)
66
    {
67 12
        $this->query = $query;
68 12
        $this->params = $params;
69 12
        $this->config = $config;
70 12
    }
71
72
    /**
73
     * @inheritDoc
74
     */
75 11
    public function getQuery()
76
    {
77 11
        return $this->query;
78
    }
79
80
    /**
81
     * @inheritDoc
82
     */
83 3
    public function getParams(): ?array
84
    {
85 3
        return $this->params;
86
    }
87
88
    /**
89
     * @inheritDoc
90
     */
91 6
    public function getConfig(): ?array
92
    {
93 6
        return $this->config;
94
    }
95
}