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

AbstractDriverException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 5
dl 0
loc 28
rs 10
c 0
b 0
f 0
ccs 6
cts 6
cp 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getSQLState() 0 3 1
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 2979
    public function __construct(string $message, ?string $sqlState = null, int $code = 0, ?Throwable $previous = null)
29
    {
30 2979
        parent::__construct($message, $code, $previous);
31
32 2979
        $this->sqlState = $sqlState;
33 2979
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38 2329
    public function getSQLState() : ?string
39
    {
40 2329
        return $this->sqlState;
41
    }
42
}
43