Total Complexity | 7 |
Total Lines | 59 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
9 | class MongoQueryLogger implements DataCollectorLoggerInterface |
||
10 | { |
||
11 | /** @var \SplQueue|Query[] */ |
||
12 | private $logs; |
||
13 | |||
14 | /** @var array|string[] */ |
||
15 | private $connections; |
||
16 | |||
17 | /** |
||
18 | * MongoQueryLogger constructor. |
||
19 | */ |
||
20 | 11 | public function __construct() |
|
21 | { |
||
22 | 11 | $this->logs = new \SplQueue(); |
|
23 | 11 | $this->connections = []; |
|
24 | 11 | } |
|
25 | |||
26 | /** |
||
27 | * @param string $connection |
||
28 | */ |
||
29 | 7 | public function addConnection(string $connection) |
|
30 | { |
||
31 | 7 | $this->connections[] = $connection; |
|
32 | 7 | } |
|
33 | |||
34 | /** |
||
35 | * @return array|\string[] |
||
36 | */ |
||
37 | 4 | public function getConnections(): array |
|
38 | { |
||
39 | 4 | return $this->connections; |
|
40 | } |
||
41 | |||
42 | /** |
||
43 | * @param Query $event |
||
44 | */ |
||
45 | 3 | public function logQuery(Query $event) |
|
48 | 3 | } |
|
49 | |||
50 | /** |
||
51 | * @return Query |
||
52 | */ |
||
53 | 3 | public function getLoggedEvent(): Query |
|
54 | { |
||
55 | 3 | if (! $this->hasLoggedEvents()) { |
|
56 | 1 | throw new \LogicException('No more events logged!'); |
|
57 | } |
||
58 | |||
59 | 3 | return $this->logs->dequeue(); |
|
60 | } |
||
61 | |||
62 | /** |
||
63 | * @return bool |
||
64 | */ |
||
65 | 4 | public function hasLoggedEvents(): bool |
|
68 | } |
||
69 | } |
||
70 |