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

MysqliException   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Test Coverage

Coverage 57.14%

Importance

Changes 0
Metric Value
wmc 4
eloc 3
dl 0
loc 10
ccs 4
cts 7
cp 0.5714
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fromStatementError() 0 3 2
A fromConnectionError() 0 3 2
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