DebugStack::startQuery()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 0
cts 5
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
crap 2
1
<?php
2
3
namespace Brouzie\Sphinxy\Logging;
4
5
/**
6
 * Includes executed SQLs in a Debug Stack.
7
 *
8
 * @author Konstantin Myakshin <[email protected]>
9
 */
10
class DebugStack implements LoggerInterface
11
{
12
    /**
13
     * READONLY
14
     * Executed SQL queries.
15
     *
16
     * @var array
17
     */
18
    public $queries = array();
19
20
    /**
21
     * @var float|null
22
     */
23
    protected $start;
24
25
    /**
26
     * @var int
27
     */
28
    protected $currentQuery = 0;
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function startQuery($sql, array $params = null)
34
    {
35
        $this->start = microtime(true);
36
        $this->queries[++$this->currentQuery] = array('sql' => $sql, 'params' => $params, 'executionMS' => 0);
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public function stopQuery()
43
    {
44
        $this->queries[$this->currentQuery]['executionMS'] = microtime(true) - $this->start;
45
    }
46
}
47