Passed
Pull Request — main (#122)
by Andreas
02:03
created

Exception   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 9
c 1
b 0
f 0
dl 0
loc 14
ccs 0
cts 7
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A new() 0 12 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Crate\DBAL\Driver\PDOCrate;
6
7
use Doctrine\DBAL\Driver\AbstractException;
8
use PDOException;
9
10
/** @internal */
11
final class Exception extends AbstractException
12
{
13
    public static function new(PDOException $exception): self
14
    {
15
        if ($exception->errorInfo !== null) {
16
            [$sqlState, $code] = $exception->errorInfo;
17
18
            $code ??= 0;
19
        } else {
20
            $code     = $exception->getCode();
21
            $sqlState = null;
22
        }
23
24
        return new self($exception->getMessage(), $sqlState, $code, $exception);
25
    }
26
}
27