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

AbstractDriverException::getErrorCode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1.125

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 1
cts 2
cp 0.5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1.125
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\DBAL\Driver;
6
7
use Exception;
8
use Throwable;
9
10
/**
11
 * Abstract base implementation of the {@link DriverException} interface.
12
 */
13
abstract class AbstractDriverException extends Exception implements DriverException
14
{
15
    /**
16
     * The SQLSTATE of the driver.
17
     *
18
     * @var string|null
19
     */
20
    private $sqlState;
21
22
    /**
23
     * @param string         $message  The driver error message.
24
     * @param string|null    $sqlState The SQLSTATE the driver is in at the time the error occurred, if any.
25
     * @param int            $code     The driver specific error code if any.
26
     * @param Throwable|null $previous The previous throwable used for the exception chaining.
27
     */
28
    public function __construct(string $message, ?string $sqlState = null, int $code = 0, ?Throwable $previous = null)
29
    {
30
        parent::__construct($message, $code, $previous);
31 1218
32
        $this->sqlState = $sqlState;
33 1218
    }
34
35 1218
    /**
36 1218
     * {@inheritdoc}
37 1218
     */
38
    public function getSQLState() : ?string
39
    {
40
        return $this->sqlState;
41
    }
42
}
43