Completed
Push — master ( 5eeedf...c04568 )
by Jacob
02:57
created

StandardDataCollector::getQueries()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Doctrine MongoDBBundle
5
 *
6
 * The code was originally distributed inside the Symfony framework.
7
 *
8
 * (c) Fabien Potencier <[email protected]>
9
 * (c) Doctrine Project
10
 *
11
 * For the full copyright and license information, please view the LICENSE
12
 * file that was distributed with this source code.
13
 */
14
15
namespace As3\Bundle\ModlrBundle\DataCollector\MongoDb;
16
17
use Symfony\Component\HttpFoundation\Request;
18
use Symfony\Component\HttpFoundation\Response;
19
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
20
21
/**
22
 * Data collector for the Doctrine MongoDB ODM.
23
 *
24
 * @author Kris Wallsmith <[email protected]>
25
 */
26
class StandardDataCollector extends DataCollector
27
{
28
    protected $queries;
29
30
    public function __construct()
31
    {
32
        $this->queries = array();
33
    }
34
35
    public function logQuery(array $query)
36
    {
37
        $this->queries[] = $query;
38
    }
39
40
    public function collect(Request $request, Response $response, \Exception $exception = null)
41
    {
42
        $this->data['nb_queries'] = count($this->queries);
43
        $this->data['queries'] = array_map('json_encode', $this->queries);
44
    }
45
46
    public function getQueryCount()
47
    {
48
        return $this->data['nb_queries'];
49
    }
50
51
    public function getQueries()
52
    {
53
        return $this->data['queries'];
54
    }
55
56
    public function getName()
57
    {
58
        return 'as3persistermongodb';
59
    }
60
}
61