Passed
Pull Request — master (#203)
by Dmitriy
04:24 queued 01:48
created

CycleCollector::collectQuery()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 7
rs 10
cc 1
nc 1
nop 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Yii\Debug\Collector\Database;
6
7
use Yiisoft\Yii\Debug\Collector\CollectorInterface;
8
use Yiisoft\Yii\Debug\Collector\CollectorTrait;
9
use Yiisoft\Yii\Debug\Collector\IndexCollectorInterface;
10
11
final class CycleCollector implements CollectorInterface, IndexCollectorInterface
12
{
13
    use CollectorTrait;
14
15
    private array $queries = [];
16
17
    public function getCollected(): array
18
    {
19
        return $this->queries;
20
    }
21
22
    public function collect(...$args): void
23
    {
24
        $this->queries[] = $args;
25
    }
26
27
    private function collectQuery(string $sql, array $params, string $line): void
0 ignored issues
show
Unused Code introduced by
The method collectQuery() is not used, and could be removed.

This check looks for private methods that have been defined, but are not used inside the class.

Loading history...
28
    {
29
        $this->queries[] = [
30
            'rawSql' => $sql,
31
            'params' => $params,
32
            'line' => $line,
33
            'time' => microtime(true),
34
        ];
35
    }
36
37
    public function getIndexData(): array
38
    {
39
        return [
40
            'cycle' => [
41
                'total' => count($this->queries),
42
            ],
43
        ];
44
    }
45
46
    private function reset(): void
0 ignored issues
show
Unused Code introduced by
The method reset() is not used, and could be removed.

This check looks for private methods that have been defined, but are not used inside the class.

Loading history...
47
    {
48
        $this->queries = [];
49
    }
50
}
51