Completed
Pull Request — master (#3759)
by Benjamin
61:16
created

PDOException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A fromNativePDOException() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\DBAL\Driver;
6
7
/**
8
 * Tiny wrapper for PDOException instances to implement the {@link DriverException} interface.
9
 */
10
class PDOException extends AbstractDriverException
11
{
12
    public static function fromNativePDOException(\PDOException $exception) : PDOException
13
    {
14
        if ($exception->errorInfo !== null) {
15
            [$sqlState, $code] = $exception->errorInfo;
16
        } else {
17
            $code     = $exception->getCode();
18
            $sqlState = null;
19
        }
20
21
        return new self($exception->getMessage(), $sqlState, $code, $exception);
22
    }
23
}
24