Code Duplication    Length = 38-47 lines in 2 locations

lib/Doctrine/DBAL/Driver/AbstractDriverException.php 1 location

@@ 29-75 (lines=47) @@
26
 * @link   www.doctrine-project.org
27
 * @since  2.5
28
 */
29
abstract class AbstractDriverException extends \Exception implements DriverException
30
{
31
    /**
32
     * The driver specific error code.
33
     *
34
     * @var integer|string|null
35
     */
36
    private $errorCode;
37
38
    /**
39
     * The SQLSTATE of the driver.
40
     *
41
     * @var string|null
42
     */
43
    private $sqlState;
44
45
    /**
46
     * Constructor.
47
     *
48
     * @param string              $message   The driver error message.
49
     * @param string|null         $sqlState  The SQLSTATE the driver is in at the time the error occurred, if any.
50
     * @param integer|string|null $errorCode The driver specific error code if any.
51
     */
52
    public function __construct($message, $sqlState = null, $errorCode = null)
53
    {
54
        parent::__construct($message);
55
56
        $this->errorCode = $errorCode;
57
        $this->sqlState  = $sqlState;
58
    }
59
60
    /**
61
     * {@inheritdoc}
62
     */
63
    public function getErrorCode()
64
    {
65
        return $this->errorCode;
66
    }
67
68
    /**
69
     * {@inheritdoc}
70
     */
71
    public function getSQLState()
72
    {
73
        return $this->sqlState;
74
    }
75
}
76

tests/Doctrine/Tests/DBAL/Driver/AbstractDriverTest.php 1 location

@@ 233-270 (lines=38) @@
230
231
        foreach ($this->getExceptionConversionData() as $convertedExceptionClassName => $errors) {
232
            foreach ($errors as $error) {
233
                $driverException = new class ($error[0], $error[1], $error[2])
234
                    extends \Exception
235
                    implements DriverException
236
                {
237
                    /**
238
                     * @var mixed
239
                     */
240
                    private $errorCode;
241
242
                    /**
243
                     * @var mixed
244
                     */
245
                    private $sqlState;
246
247
                    public function __construct($errorCode, $sqlState, $message)
248
                    {
249
                        parent::__construct($message);
250
251
                        $this->errorCode = $errorCode;
252
                        $this->sqlState  = $sqlState;
253
                    }
254
255
                    /**
256
                     * {@inheritDoc}
257
                     */
258
                    public function getErrorCode()
259
                    {
260
                        return $this->errorCode;
261
                    }
262
263
                    /**
264
                     * {@inheritDoc}
265
                     */
266
                    public function getSQLState()
267
                    {
268
                        return $this->sqlState;
269
                    }
270
                };
271
272
                $data[] = array($driverException, $convertedExceptionClassName);
273
            }