Completed
Push — develop ( 347d2f...361a2b )
by Marco
24s queued 13s
created

DriverException::getErrorCode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 1
cts 1
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\DBAL\Exception;
6
7
use Doctrine\DBAL\DBALException;
8
use Doctrine\DBAL\Driver\DriverException as DriverExceptionInterface;
9
use function assert;
10
11
/**
12
 * Base class for all errors detected in the driver.
13
 */
14
class DriverException extends DBALException implements DriverExceptionInterface
15
{
16
    /**
17
     * @param string                   $message         The exception message.
18
     * @param DriverExceptionInterface $driverException The DBAL driver exception to chain.
19
     */
20
    public function __construct(string $message, DriverExceptionInterface $driverException)
21
    {
22
        parent::__construct($message, $driverException->getCode(), $driverException);
23
    }
24 3201
25
    /**
26 3201
     * {@inheritDoc}
27
     */
28 3201
    public function getSQLState() : ?string
29 3201
    {
30
        $previous = $this->getPrevious();
31
        assert($previous instanceof DriverExceptionInterface);
32 3201
33
        return $previous->getSQLState();
34 3201
    }
35
}
36