Completed
Pull Request — master (#41)
by Rasmus
03:00
created

SQLException   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 0
loc 18
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 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          $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 1
            $code,
26 1
            $previous
27
        );
28 1
    }
29
}
30