Completed
Push — develop ( 347d2f...361a2b )
by Marco
24s queued 13s
created

MysqliException   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 3
dl 0
loc 10
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
    public static function fromConnectionError(mysqli $connection) : self
17
    {
18
        return new self($connection->error, $connection->sqlstate ?: null, $connection->errno);
19
    }
20
21
    public static function fromStatementError(mysqli_stmt $statement) : self
22
    {
23
        return new self($statement->error, $statement->sqlstate ?: null, $statement->errno);
24
    }
25
}
26