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

MongoDbDataCollector   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 44
ccs 0
cts 23
cp 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A collect() 0 11 1
A getQueryCount() 0 4 1
A getTime() 0 4 1
A getName() 0 4 1
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