Db   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Test Coverage

Coverage 86.96%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 31
c 3
b 0
f 0
dl 0
loc 78
ccs 20
cts 23
cp 0.8696
rs 10
wmc 8

4 Methods

Rating   Name   Duplication   Size   Complexity  
A lastInsertId() 0 3 1
A queryOne() 0 8 2
A queryRow() 0 8 2
A quote() 0 12 3
1
<?php
2
/**
3
* MDB2 Wrapper Made To Handle Like Our Other Classes Related Functionality
4
* @author Joe Huss <[email protected]>
5
* @copyright 2025
6
* @package MyAdmin
7
* @category SQL
8
*/
9
10
namespace MyDb\Mdb2;
11
12
use MyDb\Generic;
13
use MyDb\Mysqli\Db as MysqliDb;
14
use MyDb\Db_Interface;
15
16
/**
17
 * Db
18
 *
19
 * @access public
20
 */
21
class Db extends MysqliDb implements Db_Interface
22
{
23
    public $host = 'localhost';
24
    public $user = 'pdns';
25
    public $password = '';
26
    public $database = 'pdns';
27
    public $type = 'mdb2';
28
    public $error = false;
29
    public $message = '';
30
31
    /**
32
     * Db::quote()
33
     * @param string $text
34
     * @param string $type
35
     * @return string
36
     */
37 1
    public function quote($text = '', $type = 'text')
38
    {
39
        switch ($type) {
40 1
            case 'text':
41 1
                return "'".$this->escape($text)."'";
42
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
43 1
            case 'integer':
44 1
                return (int) $text;
45
                break;
46
            default:
47 1
                return $text;
48
                break;
49
        }
50
    }
51
52
    /**
53
     * Db::queryOne()
54
     *
55
     * @param mixed $query
56
     * @param string $line
57
     * @param string $file
58
     * @return bool
59
     */
60 1
    public function queryOne($query, $line = '', $file = '')
61
    {
62 1
        $this->query($query, $line, $file);
0 ignored issues
show
Bug introduced by
$line of type string is incompatible with the type integer expected by parameter $line of MyDb\Mysqli\Db::query(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

62
        $this->query($query, /** @scrutinizer ignore-type */ $line, $file);
Loading history...
63 1
        if ($this->num_rows() > 0) {
64 1
            $this->next_record();
65 1
            return $this->f(0);
66
        } else {
67 1
            return 0;
68
        }
69
    }
70
71
    /**
72
     * Db::queryRow()
73
     *
74
     * @param mixed $query
75
     * @param string $line
76
     * @param string $file
77
     * @return array|bool
78
     */
79 1
    public function queryRow($query, $line = '', $file = '')
80
    {
81 1
        $this->query($query, $line, $file);
0 ignored issues
show
Bug introduced by
$line of type string is incompatible with the type integer expected by parameter $line of MyDb\Mysqli\Db::query(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

81
        $this->query($query, /** @scrutinizer ignore-type */ $line, $file);
Loading history...
82 1
        if ($this->num_rows() > 0) {
83 1
            $this->next_record();
84 1
            return $this->Record;
85
        } else {
86 1
            return 0;
87
        }
88
    }
89
90
    /**
91
     * Db::lastInsertId()
92
     * @param mixed $table
93
     * @param mixed $field
94
     * @return int
95
     */
96 1
    public function lastInsertId($table, $field)
97
    {
98 1
        return $this->getLastInsertId($table, $field);
99
    }
100
}
101