Test Failed
Pull Request — master (#178)
by Def
07:51 queued 05:16
created

CommandPDO::queryBuilder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 0
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Mysql;
6
7
use PDOException;
8
use Throwable;
9
use Yiisoft\Db\Driver\PDO\CommandPDO as AbstractCommandPDO;
10
use Yiisoft\Db\Driver\PDO\ConnectionPDOInterface;
11
use Yiisoft\Db\Exception\ConvertException;
12
use Yiisoft\Db\QueryBuilder\QueryBuilderInterface;
13
14
final class CommandPDO extends AbstractCommandPDO
15
{
16
    public function queryBuilder(): QueryBuilderInterface
17
    {
18
        return $this->db->getQueryBuilder();
19 1
    }
20
21 1
    /**
22 1
     * @psalm-suppress UnusedClosureParam
23 1
     *
24
     * @throws Throwable
25 1
     */
26
    protected function internalExecute(string|null $rawSql): void
27
    {
28
        $attempt = 0;
29 1
30 1
        while (true) {
31
            try {
32 1
                if (
33 1
                    ++$attempt === 1
34 1
                    && $this->isolationLevel !== null
35 1
                    && $this->db->getTransaction() === null
36 1
                ) {
37
                    $this->db->transaction(
38
                        fn (ConnectionPDOInterface $db) => $this->internalExecute($rawSql),
0 ignored issues
show
Unused Code introduced by
The parameter $db is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

38
                        fn (/** @scrutinizer ignore-unused */ ConnectionPDOInterface $db) => $this->internalExecute($rawSql),

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
39
                        $this->isolationLevel,
40
                    );
41
                } else {
42
                    $this->pdoStatement?->execute();
43 1
                }
44
                break;
45
            } catch (PDOException $e) {
46 231
                $rawSql = $rawSql ?: $this->getRawSql();
47
                $e = (new ConvertException($e, $rawSql))->run();
48 231
49
                if ($this->retryHandler === null || !($this->retryHandler)($e, $attempt)) {
50
                    throw $e;
51
                }
52
            }
53
        }
54
    }
55
}
56