Passed
Branch v0.1 (e1d14a)
by Nestor
01:33
created

Exception::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 4
1
<?php
2
3
namespace Cozy\Database\Relational;
4
5
class Exception extends \RuntimeException
6
{
7
    /** @var string */
8
    protected $sentence;
9
    /** @var string */
10
    protected $code;
11
    /** @var array */
12
    protected $errorInfo = [];
13
14
    /**
15
     * Exception constructor.
16
     *
17
     * @param string $message
18
     * @param mixed $code
19
     * @param array $error_info
20
     * @param string|null $sentence
21
     */
22
    public function __construct(string $message = '', $code = null, array $error_info = [], string $sentence = '')
23
    {
24
        parent::__construct($message, 0);
25
26
        $this->code = $code;
27
        $this->errorInfo = $error_info;
28
        $this->sentence = $sentence;
29
    }
30
31
    /**
32
     * Gets the SQL sentence
33
     * @return string the SQL sentence as a string.
34
     */
35
    public function getSentence(): string
36
    {
37
        return $this->sentence;
38
    }
39
40
    /**
41
     * Gets detailed information of error
42
     * @return array the PDO error information as an array.
43
     */
44
    public function getErrorInfo(): array
45
    {
46
        return $this->errorInfo;
47
    }
48
}
49