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

MysqliException::fromStatementError()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 2
nc 1
nop 1
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