Completed
Push — develop ( fa42c1...0ef7d4 )
by Sergei
22:52
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
abstract class AbstractDriverException extends Exception implements DriverException
11
{
12
    /**
13
     * The driver specific error code.
14
     *
15
     * @var int|string|null
16
     */
17
    private $errorCode;
18
19
    /**
20
     * The SQLSTATE of the driver.
21
     *
22
     * @var string|null
23
     */
24
    private $sqlState;
25
26
    /**
27
     * @param string          $message   The driver error message.
28
     * @param string|null     $sqlState  The SQLSTATE the driver is in at the time the error occurred, if any.
29
     * @param int|string|null $errorCode The driver specific error code if any.
30
     */
31 1051
    public function __construct($message, $sqlState = null, $errorCode = null)
32
    {
33 1051
        parent::__construct($message);
34
35 1051
        $this->errorCode = $errorCode;
36 1051
        $this->sqlState  = $sqlState;
37 1051
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42 927
    public function getErrorCode()
43
    {
44 927
        return $this->errorCode;
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50
    public function getSQLState()
51
    {
52
        return $this->sqlState;
53
    }
54
}
55