SQLLogger   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 51
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A startQuery() 0 9 1
A stopQuery() 0 4 1
A getCurrentBenchmark() 0 4 1
A setCurrentBenchmark() 0 4 1
1
<?php
2
/**
3
 * @author Fabian Fuelling <[email protected]>
4
 * @created: 17.12.14 17:11
5
 */
6
7
namespace Fabfuel\Prophiler\Adapter\Doctrine;
8
9
use Doctrine\DBAL\Logging\SQLLogger as DoctrineSQLLogger;
10
use Fabfuel\Prophiler\Adapter\AdapterAbstract;
11
use Fabfuel\Prophiler\Benchmark\BenchmarkInterface;
12
13
class SQLLogger extends AdapterAbstract implements DoctrineSQLLogger
14
{
15
    /**
16
     * @var BenchmarkInterface
17
     */
18
    protected $currentBenchmark;
19
20
    /**
21
     * Logs a SQL statement
22
     *
23
     * @param string $sql The SQL to be executed
24
     * @param array|null $params The SQL parameters
25
     * @param array|null $types The SQL parameter types
26
     * @return void
27
     */
28 1
    public function startQuery($sql, array $params = null, array $types = null)
29
    {
30
        $metadata = [
31 1
            'query' => $sql,
32 1
            'params' => $params,
33 1
            'types' => $types,
34 1
        ];
35 1
        $this->setCurrentBenchmark($this->profiler->start('Doctrine::query', $metadata, 'Database'));
36 1
    }
37
38
    /**
39
     * Marks the last started query as stopped
40
     *
41
     * @return void
42
     */
43 1
    public function stopQuery()
44
    {
45 1
        $this->profiler->stop($this->getCurrentBenchmark());
46 1
    }
47
48
    /**
49
     * @return BenchmarkInterface
50
     */
51 1
    public function getCurrentBenchmark()
52
    {
53 1
        return $this->currentBenchmark;
54
    }
55
56
    /**
57
     * @param BenchmarkInterface $currentBenchmark
58
     */
59 1
    public function setCurrentBenchmark(BenchmarkInterface $currentBenchmark)
60
    {
61 1
        $this->currentBenchmark = $currentBenchmark;
62 1
    }
63
}
64