Passed
Push — main ( faeaf0...5f5b5b )
by Thierry
36:26 queued 28:38
created

History::queries()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Lagdo\DbAdmin\Driver\Utils;
4
5
use function intval;
6
use function microtime;
7
use function preg_match;
8
9
class History
10
{
11
    /**
12
     * Executed queries
13
     *
14
     * @var array
15
     */
16
    protected $queries = [];
17
18
    /**
19
     * Save a query in the history
20
     *
21
     * @param string $query
22
     *
23
     * @return void
24
     */
25
    public function save(string $query)
26
    {
27
        $this->queries[] = [
28
            'start' => intval(microtime(true)),
29
            'query' => (preg_match('~;$~', $query) ? "DELIMITER ;;\n$query;\nDELIMITER " : $query),
30
        ];
31
    }
32
33
    /**
34
     * Get the remembered queries
35
     *
36
     * @return array
37
     */
38
    public function queries()
39
    {
40
        return $this->queries;
41
    }
42
}
43