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

StandardDataCollector   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 6
c 1
b 0
f 1
lcom 1
cbo 1
dl 0
loc 35
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A logQuery() 0 4 1
A collect() 0 5 1
A getQueryCount() 0 4 1
A getQueries() 0 4 1
A getName() 0 4 1
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