Completed
Pull Request — master (#8)
by Alessandro
06:32
created

MongoDbDataCollector::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Facile\MongoDbBundle\DataCollector;
6
7
use Symfony\Component\HttpFoundation\Request;
8
use Symfony\Component\HttpFoundation\Response;
9
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
10
11
/**
12
 * Class MongoDbDataCollector.
13
 */
14
final class MongoDbDataCollector extends DataCollector
15
{
16
    const QUERY_KEYWORD = 'queries';
17
    const CONNECTION_KEYWORD = 'connections';
18
19
    /**
20
     * {@inheritdoc}
21
     */
22
    public function collect(Request $request, Response $response, \Exception $exception = null)
23
    {
24
        $this->data = [
25
            self::QUERY_KEYWORD => [
26
                'findOne' => '{"_id" => 1}',
27
            ],
28
            self::CONNECTION_KEYWORD => [
29
                'test_db',
30
            ],
31
        ];
32
    }
33
34
    /**
35
     * @return int
36
     */
37
    public function getQueryCount(): int
38
    {
39
        return count($this->data[self::QUERY_KEYWORD]);
40
    }
41
42
    /**
43
     * @return float
44
     */
45
    public function getTime(): float
46
    {
47
        return 0.25;
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53
    public function getName()
54
    {
55
        return 'mongodb';
56
    }
57
}
58