Passed
Push — drop-deprecated ( db0b1f )
by Michael
27:00
created

MysqliException::fromConnectionError()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2.1481

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 3
cp 0.6667
rs 10
c 0
b 0
f 0
cc 2
nc 1
nop 1
crap 2.1481
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\DBAL\Driver\Mysqli;
6
7
use Doctrine\DBAL\Driver\AbstractDriverException;
8
use mysqli;
9
use mysqli_stmt;
10
11
/**
12
 * Exception thrown in case the mysqli driver errors.
13
 */
14
class MysqliException extends AbstractDriverException
15
{
16 862
    public static function fromConnectionError(mysqli $connection) : self
17
    {
18 862
        return new self($connection->error, $connection->sqlstate ?: null, $connection->errno);
19
    }
20
21 834
    public static function fromStatementError(mysqli_stmt $statement) : self
22
    {
23 834
        return new self($statement->error, $statement->sqlstate ?: null, $statement->errno);
24
    }
25
}
26