Completed
Push — 3.1 ( 729bad...a28158 )
by Raphaël
11:42 queued 12s
created

ZohoSyncSQLLogger::stopQuery()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
namespace Wabel\Zoho\CRM\Copy\Log;
3
4
use Doctrine\DBAL\Connection;
5
use Doctrine\DBAL\Logging\SQLLogger;
6
use Doctrine\DBAL\SQLParserUtils;
7
use function PHPSTORM_META\type;
8
use Psr\Log\LoggerInterface;
9
10
class ZohoSyncSQLLogger implements SQLLogger
11
{
12
13
    /**
14
     * @var LoggerInterface
15
     */
16
    private $logger;
17
18
    /**
19
     * @var Connection
20
     */
21
    private $connection;
22
    /**
23
     * @var bool
24
     */
25
    private $authorizedSQLWithoutParams;
26
    /**
27
     * @var bool
28
     */
29
    private $authorizedSQLWithParams;
30
31
    /**
32
     * ZohoSyncSQLLogger constructor.
33
     * @param LoggerInterface $logger
34
     * @param Connection $connection
35
     * @param bool $authorizedSQLWithoutParams
36
     * @param bool $authorizedSQLWithParams
37
     */
38
    public function __construct(LoggerInterface $logger, Connection $connection, $authorizedSQLWithoutParams = false, $authorizedSQLWithParams = false)
39
    {
40
        $this->logger = $logger;
41
        $this->connection = $connection;
42
        $this->authorizedSQLWithoutParams = $authorizedSQLWithoutParams;
43
        $this->authorizedSQLWithParams = $authorizedSQLWithParams;
44
    }
45
46
    /**
47
     * Logs a SQL statement somewhere.
48
     *
49
     * @param string $sql The SQL to be executed.
50
     * @param array|null $params The SQL parameters.
51
     * @param array|null $types The SQL parameter types.
52
     *
53
     * @return void
54
     */
55
    public function startQuery($sql, array $params = null, array $types = null)
56
    {
57
        $query = null;
0 ignored issues
show
Unused Code introduced by
$query is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
58
        if ($params && $this->authorizedSQLWithParams) {
59
            $this->logger->debug($sql.' -- Params : {params} - Types : {types}', ['params' => json_encode($params), 'types' => json_encode($types)]);
60
        } elseif($this->authorizedSQLWithoutParams) {
61
            $this->logger->debug($sql);
62
        }
63
    }
64
65
    /**
66
     * Marks the last started query as stopped. This can be used for timing of queries.
67
     *
68
     * @return void
69
     */
70
    public function stopQuery()
71
    {
72
    }
73
}