Passed
Push — 2.10.x ( 03f139...aab745 )
by Sergei
25:22
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.037

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 2
cts 3
cp 0.6667
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
crap 1.037
1
<?php
2
3
namespace Doctrine\DBAL\Driver;
4
5
use Exception;
6
7
/**
8
 * Abstract base implementation of the {@link DriverException} interface.
9
 *
10
 * @psalm-immutable
11
 */
12
abstract class AbstractDriverException extends Exception implements DriverException
13
{
14
    /**
15
     * The driver specific error code.
16
     *
17
     * @var int|string|null
18
     */
19
    private $errorCode;
20
21
    /**
22
     * The SQLSTATE of the driver.
23
     *
24
     * @var string|null
25
     */
26
    private $sqlState;
27
28
    /**
29
     * @param string          $message   The driver error message.
30
     * @param string|null     $sqlState  The SQLSTATE the driver is in at the time the error occurred, if any.
31
     * @param int|string|null $errorCode The driver specific error code if any.
32
     */
33 1015
    public function __construct($message, $sqlState = null, $errorCode = null)
34
    {
35 1015
        parent::__construct($message);
36
37 1015
        $this->errorCode = $errorCode;
38 1015
        $this->sqlState  = $sqlState;
39 1015
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44 998
    public function getErrorCode()
45
    {
46 998
        return $this->errorCode;
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function getSQLState()
53
    {
54
        return $this->sqlState;
55
    }
56
}
57