Completed
Push — master ( 18c7f8...c29312 )
by Tobias
10:28
created

Neo4jDataCollector   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 2
dl 0
loc 62
ccs 0
cts 30
cp 0
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A collect() 0 6 1
A getQueryCount() 0 4 1
A getStatements() 0 4 1
A getTime() 0 4 1
A getTimeForQuery() 0 4 1
A getName() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Neo4j\Neo4jBundle\Collector;
6
7
use Symfony\Component\HttpFoundation\Request;
8
use Symfony\Component\HttpFoundation\Response;
9
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
10
11
/**
12
 * @author Xavier Coureau <[email protected]>
13
 */
14
final class Neo4jDataCollector extends DataCollector
15
{
16
    /**
17
     * @var QueryLogger
18
     */
19
    private $queryLogger;
20
21
    public function __construct(QueryLogger $logger)
22
    {
23
        $this->queryLogger = $logger;
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function collect(Request $request, Response $response, \Exception $exception = null)
30
    {
31
        $this->data['nb_queries'] = count($this->queryLogger);
32
        $this->data['statements'] = $this->queryLogger->getStatements();
33
        $this->data['time'] = $this->queryLogger->getElapsedTime();
34
    }
35
36
    /**
37
     * @return int
38
     */
39
    public function getQueryCount()
40
    {
41
        return $this->data['nb_queries'];
42
    }
43
44
    /**
45
     * @return QueryLogger
46
     */
47
    public function getStatements()
48
    {
49
        return $this->data['statements'];
50
    }
51
52
    /**
53
     * @return float
54
     */
55
    public function getTime()
56
    {
57
        return $this->data['time'];
58
    }
59
60
    /**
61
     * @return float
62
     */
63
    public function getTimeForQuery()
64
    {
65
        return $this->data['time'];
66
    }
67
68
    /**
69
     * @return string
70
     */
71
    public function getName()
72
    {
73
        return 'neo4j';
74
    }
75
}
76