Passed
Push — master ( 3880dd...1a3c5e )
by Ilario
04:06
created

Query::getExecutionTime()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 0
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Facile\MongoDbBundle\Models;
6
7
/**
8
 * Class Query.
9
 *
10
 * @internal
11
 */
12
final class Query
13
{
14
    /** @var float */
15
    private $start;
16
17
    /** @var string */
18
    private $method;
19
20
    /** @var string */
21
    private $collection;
22
23
    /** @var array */
24
    private $filters;
25
26
    /** @var array|object */
27
    private $data;
28
29
    /** @var array */
30
    private $options;
31
32
    /** @var float */
33
    private $executionTime;
34
35 34
    /** @var string */
36
    private $readPreference;
37 34
38 34
    /** @var string */
39 34
    private $client;
40 34
41 34
    /** @var string */
42 34
    private $database;
43 34
44 34
    /**
45 34
     * Query constructor.
46 34
     */
47 34
    public function __construct()
48
    {
49
        $this->start = microtime(true);
50
        $this->client = 'undefined';
51
        $this->database = 'undefined';
52 13
        $this->collection = 'undefined';
53
        $this->method = 'undefined';
54 13
        $this->filters = [];
55
        $this->data = [];
56
        $this->options = [];
57
        $this->executionTime = 0;
58
        $this->readPreference = 'undefined';
59
    }
60 12
61
    /**
62 12
     * @return float
63
     */
64
    public function getStart(): float
65
    {
66
        return $this->start;
67
    }
68 24
69
    /**
70 24
     * @return string
71 24
     */
72
    public function getCollection(): string
73
    {
74
        return $this->collection;
75
    }
76 14
77
    /**
78 14
     * @param string $collection
79
     */
80
    public function setCollection(string $collection)
81
    {
82
        $this->collection = $collection;
83
    }
84 26
85
    /**
86 26
     * @return string
87 26
     */
88
    public function getMethod(): string
89
    {
90
        return $this->method;
91
    }
92 28
93
    /**
94 28
     * @param string $method
95
     */
96
    public function setMethod(string $method)
97
    {
98
        $this->method = $method;
99
    }
100 31
101
    /**
102 31
     * @return array
103 31
     */
104
    public function getFilters(): array
105
    {
106
        return $this->filters;
107
    }
108 14
109
    /**
110 14
     * @param array|object $filters
111
     */
112
    public function setFilters($filters)
113
    {
114
        $this->filters = (array) ($filters ?? []);
115
    }
116 20
117
    /**
118 20
     * @return array|object
119 20
     */
120
    public function getData()
121
    {
122
        return $this->data;
123
    }
124 27
125
    /**
126 27
     * @param array|object $data
127
     */
128
    public function setData($data): void
129
    {
130
        $this->data = $data ?? [];
131
    }
132 20
133
    /**
134 20
     * @return array
135 20
     */
136
    public function getOptions(): array
137
    {
138
        return $this->options;
139
    }
140 2
141
    /**
142 2
     * @param array $options
143
     */
144
    public function setOptions(array $options)
145
    {
146
        $this->options = $options;
147
    }
148 13
149
    /**
150 13
     * @return float
151 13
     */
152
    public function getExecutionTime(): float
153
    {
154
        return $this->executionTime;
155
    }
156 1
157
    public function setExecutionTime(float $executionTime)
158 1
    {
159
        $this->executionTime = $executionTime;
160
    }
161
162
    /**
163
     * @return string
164 13
     */
165
    public function getReadPreference(): string
166 13
    {
167 13
        return $this->readPreference;
168
    }
169
170
    /**
171
     * @param string $readPreference
172 3
     */
173
    public function setReadPreference(string $readPreference)
174 3
    {
175
        $this->readPreference = $readPreference;
176
    }
177
178
    /**
179
     * @return string
180 16
     */
181
    public function getClient(): string
182 16
    {
183 16
        return $this->client;
184
    }
185
186
    /**
187
     * @param string $client
188 3
     */
189
    public function setClient(string $client)
190 3
    {
191
        $this->client = $client;
192
    }
193
194
    /**
195
     * @return string
196 16
     */
197
    public function getDatabase(): string
198 16
    {
199 16
        return $this->database;
200
    }
201
202
    /**
203
     * @param string $database
204
     */
205
    public function setDatabase(string $database)
206
    {
207
        $this->database = $database;
208
    }
209
}
210