Passed
Pull Request — master (#3353)
by Sean
14:43
created

AbstractDriverException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Test Coverage

Coverage 77.78%

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 48
rs 10
c 0
b 0
f 0
eloc 8
ccs 7
cts 9
cp 0.7778

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getSQLState() 0 3 1
A __construct() 0 10 1
A getErrorCode() 0 3 1
1
<?php
2
3
namespace Doctrine\DBAL\Driver;
4
5
use Exception;
6
use Throwable;
7
8
/**
9
 * Abstract base implementation of the {@link DriverException} interface.
10
 */
11
abstract class AbstractDriverException extends Exception implements DriverException
12
{
13
    /**
14
     * The driver specific error code.
15
     *
16
     * @var int|string|null
17
     */
18
    private $errorCode;
19
20
    /**
21
     * The SQLSTATE of the driver.
22
     *
23
     * @var string|null
24
     */
25
    private $sqlState;
26
27
    /**
28
     * @param string          $message   The driver error message.
29
     * @param string|null     $sqlState  The SQLSTATE the driver is in at the time the error occurred, if any.
30
     * @param int|string|null $errorCode The driver specific error code if any.
31
     * @param Throwable|null  $previous  The previous exception.
32
     */
33 1075
    public function __construct(
34
        $message,
35
        $sqlState = null,
36
        $errorCode = null,
37
        Throwable $previous = null
38
    ) {
39 1075
        parent::__construct($message, 0, $previous);
40
41 1075
        $this->errorCode = $errorCode;
42 1075
        $this->sqlState  = $sqlState;
43 1075
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48 927
    public function getErrorCode()
49
    {
50 927
        return $this->errorCode;
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    public function getSQLState()
57
    {
58
        return $this->sqlState;
59
    }
60
}
61