Completed
Pull Request — master (#3772)
by Christoph
51:54
created

PDOException::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 10
rs 10
c 0
b 0
f 0
ccs 6
cts 6
cp 1
cc 2
nc 2
nop 1
crap 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
    /**
13
     * @param \PDOException $exception The PDO exception to wrap.
14
     */
15 1869
    public function __construct(\PDOException $exception)
16
    {
17 1869
        if ($exception->errorInfo !== null) {
18 1865
            [$sqlState, $code] = $exception->errorInfo;
19
        } else {
20 1504
            $code     = $exception->getCode();
21 1504
            $sqlState = null;
22
        }
23
24 1869
        parent::__construct($exception->getMessage(), $sqlState, $code, $exception);
25 1869
    }
26
}
27