Completed
Push — master ( eed00d...bda091 )
by Dmitry
10:44
created

Exception   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 44.44%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 39
rs 10
c 0
b 0
f 0
ccs 4
cts 9
cp 0.4444

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getName() 0 4 1
A __toString() 0 5 1
1
<?php
2
/**
3
 * @link http://www.yiiframework.com/
4
 * @copyright Copyright (c) 2008 Yii Software LLC
5
 * @license http://www.yiiframework.com/license/
6
 */
7
8
namespace yii\db;
9
10
/**
11
 * Exception represents an exception that is caused by some DB-related operations.
12
 *
13
 * @author Qiang Xue <[email protected]>
14
 * @since 2.0
15
 */
16
class Exception extends \yii\base\Exception
17
{
18
    /**
19
     * @var array the error info provided by a PDO exception. This is the same as returned
20
     * by [PDO::errorInfo](http://www.php.net/manual/en/pdo.errorinfo.php).
21
     */
22
    public $errorInfo = [];
23
24
25
    /**
26
     * Constructor.
27
     * @param string $message PDO error message
28
     * @param array $errorInfo PDO error info
29
     * @param int $code PDO error code
30
     * @param \Exception $previous The previous exception used for the exception chaining.
31
     */
32 33
    public function __construct($message, $errorInfo = [], $code = 0, \Exception $previous = null)
33
    {
34 33
        $this->errorInfo = $errorInfo;
35 33
        parent::__construct($message, $code, $previous);
36 33
    }
37
38
    /**
39
     * @return string the user-friendly name of this exception
40
     */
41
    public function getName()
42
    {
43
        return 'Database Exception';
44
    }
45
46
    /**
47
     * @return string readable representation of exception
48
     */
49
    public function __toString()
50
    {
51
        return parent::__toString() . PHP_EOL
52
        . 'Additional Information:' . PHP_EOL . print_r($this->errorInfo, true);
53
    }
54
}
55