SQLException::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
c 0
b 0
f 0
nc 1
nop 5
dl 0
loc 11
ccs 5
cts 5
cp 1
crap 1
rs 10
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<string,mixed> $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(
22
        string $sql,
23
        array $params = [],
24
        string $message = 'SQL Error',
25
        int $code = 0,
26
        Exception|null $previous = null
27
    ) {
28 1
        parent::__construct(
29 1
            "{$message}\n" . QueryFormatter::formatQuery($sql, $params),
30 1
            $code,
31 1
            $previous
32 1
        );
33
    }
34
}
35