GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 75bdf9...8faa57 )
by joseph
83:56 queued 81:04
created

QueryCachingLogger   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 30
dl 0
loc 47
ccs 0
cts 31
cp 0
rs 10
c 0
b 0
f 0
wmc 11

3 Methods

Rating   Name   Duplication   Size   Complexity  
B run() 0 33 9
A stopQuery() 0 3 1
A startQuery() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Testing\Fixtures;
4
5
use Doctrine\DBAL\Connection;
6
use Doctrine\DBAL\Logging\SQLLogger;
7
use EdmondsCommerce\DoctrineStaticMeta\Exception\DoctrineStaticMetaException;
8
9
/**
10
 * This class is caches queries so that they can be run as quickly as possible on subsequent builds
11
 *
12
 * @see \EdmondsCommerce\DoctrineStaticMeta\Entity\Testing\Fixtures\FixturesHelper::createDb
13
 */
14
class QueryCachingLogger implements SQLLogger
15
{
16
    private $queries = [];
17
18
    public function startQuery($sql, array $params = null, array $types = null)
19
    {
20
        $this->queries[$sql][] = [$params, $types];
21
    }
22
23
    public function stopQuery()
24
    {
25
        return;
26
    }
27
28
    public function run(Connection $connection): void
29
    {
30
        foreach ($this->queries as $query => $paramsArray) {
31
            if ('"START TRANSACTION"' === $query) {
32
                $connection->beginTransaction();
33
                continue;
34
            }
35
            if ('"COMMIT"' === $query) {
36
                $connection->commit();
37
                continue;
38
            }
39
            if ([[[], []]] === $paramsArray) {
40
                $connection->prepare($query)->execute();
41
                continue;
42
            }
43
            $stmt = $connection->prepare($query);
44
            foreach ($paramsArray as $paramsTypes) {
45
                try {
46
                    list($params, $types) = $paramsTypes;
47
                    $colNum = 1;
48
                    foreach ($params as $key => $value) {
49
                        $stmt->bindValue($colNum++, $value, $types[$key]);
50
                    }
51
                    $stmt->execute();
52
                } catch (\Exception $e) {
53
                    if ($connection->isTransactionActive()) {
54
                        $connection->rollBack();
55
                    }
56
                    throw new DoctrineStaticMetaException(
57
                        'Failed running logged query ' . $query . 'with params and types: '
58
                        . print_r($paramsTypes, true),
59
                        $e->getCode(),
60
                        $e
61
                    );
62
                }
63
            }
64
        }
65
    }
66
}
67