Passed
Pull Request — develop (#92)
by Felipe
04:25
created

ADOdbException::__construct()   C

Complexity

Conditions 7
Paths 20

Size

Total Lines 32
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 7
eloc 23
nc 20
nop 7
dl 0
loc 32
rs 6.7272
c 0
b 0
f 0
1
<?php
2
/*
0 ignored issues
show
Coding Style introduced by
You must use "/**" style comments for a file comment
Loading history...
3
 * PHPPgAdmin v6.0.0-beta.30
4
 */
5
namespace PHPPgAdmin;
6
7
/**
8
 * Released under both BSD license and Lesser GPL library license. Whenever
9
 * there is any discrepancy between the two licenses, the BSD license will take
10
 * precedence.
11
 *
12
 * Set tabs to 4 for best viewing.
13
 *
14
 * Latest version is available at http://php.weblogs.com
15
 *
16
 * Exception-handling code using PHP5 exceptions (try-catch-throw).
17
 *
18
 * @copyright 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
0 ignored issues
show
Coding Style introduced by
The tag in position 1 should be the @package tag
Loading history...
19
 * @copyright 2014      Damien Regad, Mark Newnham and the ADOdb community
0 ignored issues
show
Coding Style introduced by
The tag in position 2 should be the @author tag
Loading history...
20
 * @version   v5.20.9
0 ignored issues
show
Coding Style introduced by
Invalid version "v5.20.9" in doc comment; consider "Release: <package_version>" instead
Loading history...
Coding Style introduced by
The tag in position 3 should be the @copyright tag
Loading history...
21
 * @author John Lim
1 ignored issue
show
Coding Style introduced by
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
Coding Style introduced by
The tag in position 4 should be the @license tag
Loading history...
22
 * @license MIT
1 ignored issue
show
Coding Style introduced by
@license tag must contain a URL and a license name
Loading history...
23
 * @package PHPPgAdmin
0 ignored issues
show
Coding Style introduced by
The tag in position 6 should be the @version tag
Loading history...
24
 */
2 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
25
class ADOdbException extends \Exception
26
{
27
    public $dbms;
28
    public $fn;
29
    public $sql      = '';
30
    public $params   = '';
31
    public $host     = '';
32
    public $database = '';
33
34
    public function __construct($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection)
1 ignored issue
show
Coding Style introduced by
Missing function doc comment
Loading history...
35
    {
36
        switch ($fn) {
37
            case 'EXECUTE':
38
                $this->sql    = is_array($p1) ? $p1[0] : $p1;
39
                $this->params = $p2;
40
                $s            = "$dbms error: [$errno: $errmsg] in $fn(\"$this->sql\")";
41
                break;
42
43
            case 'PCONNECT':
44
            case 'CONNECT':
45
                $user = $thisConnection->user;
46
                $s    = "$dbms error: [$errno: $errmsg] in $fn($p1, '$user', '****', $p2)";
47
                break;
48
            default:
49
                $s = "$dbms error: [$errno: $errmsg] in $fn($p1, $p2)";
50
                break;
51
        }
52
53
        $this->dbms = $dbms;
54
        if ($thisConnection) {
55
            $this->host     = $thisConnection->host;
56
            $this->database = $thisConnection->database;
57
        }
58
        $this->fn  = $fn;
59
        $this->msg = $errmsg;
60
61
        if (!is_numeric($errno)) {
62
            $errno = -1;
63
        }
64
65
        parent::__construct($s, $errno);
66
    }
67
}
68