ConnectionError::new()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2.0625

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 1
dl 0
loc 10
ccs 6
cts 8
cp 0.75
crap 2.0625
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\DBAL\Driver\Mysqli\Exception;
6
7
use Doctrine\DBAL\Driver\Mysqli\MysqliException;
8
use mysqli;
9
10
/**
11
 * @psalm-immutable
12
 */
13
final class ConnectionError extends MysqliException
14
{
15 553
    public static function new(mysqli $connection) : self
16
    {
17 553
        $connectionSQLState = $connection->sqlstate;
18
19 553
        $sqlState = null;
20 553
        if ($connectionSQLState !== false) {
0 ignored issues
show
introduced by
The condition $connectionSQLState !== false is always true.
Loading history...
21 524
            $sqlState = $connectionSQLState;
22
        }
23
24 553
        return new self($connection->error, $sqlState, $connection->errno);
25
    }
26
}
27