ConnectionError   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Test Coverage

Coverage 75%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 12
ccs 6
cts 8
cp 0.75
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A new() 0 10 2
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