Completed
Push — master ( f5e696...7c0e7c )
by Rasmus
03:36
created

SQLException::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1.0046

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 5
cts 6
cp 0.8333
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 5
crap 1.0046
1
<?php
2
3
namespace mindplay\sql\exceptions;
4
5
use Exception;
6
use mindplay\sql\framework\QueryFormatter;
7
use RuntimeException;
8
9
/**
10
 * This Exception-type represents an SQL error
11
 */
12
class SQLException extends RuntimeException
13
{
14
    /**
15
     * @param string         $sql    SQL statement (with ":name" placeholders)
16
     * @param array          $params map of parameter name/value pairs (to bind against placeholders in the statement)
17
     * @param string         $message
18
     * @param int            $code
19
     * @param Exception|null $previous
20
     */
21 1
    public function __construct($sql, $params = [], $message = 'SQL Error', $code = 0, Exception $previous = null)
22
    {
23 1
        parent::__construct(
24 1
            "{$message}\n" . QueryFormatter::formatQuery($sql, $params),
25
            $code,
26 1
            $previous
27
        );
28 1
    }
29
}
30