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

AbstractDriverException::getErrorCode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
eloc 1
ccs 2
cts 2
cp 1
cc 1
nc 1
nop 0
crap 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