SQLException   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 5
c 0
b 0
f 0
dl 0
loc 20
ccs 5
cts 5
cp 1
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
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