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

Neo4jDataCollector::getQueryCount()   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
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
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