Test Failed
Branch main (71ef7e)
by Rafael
10:37 queued 05:04
created

DB::getDataTypes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Copyright (C) 2022-2023  Rafael San José Tovar   <[email protected]>
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation; either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17
 */
18
19
namespace Alxarafe\Database;
20
21
use Alxarafe\Core\Singletons\Config;
22
use Alxarafe\Database\SqlHelpers\SqlMySql;
23
use PDO;
24
25
/**
26
 * Class DB
27
 *
28
 * Esta clase proporciona acceso directo a la base de datos.
29
 *
30
 * @author  Rafael San José Tovar <[email protected]>
31
 * @version 2022.0721
32
 *
33
 */
34
class DB
35
{
36
    /**
37
     * Motor utilizado, puede ser MySql, MariaDB, PostgreSql o cualquier otro PDO
38
     *
39
     * @var Engine
40
     */
41
    public static $engine;
42
43
    public static $sqlHelper;
44
45
    public function __construct()
46
    {
47
        self::$engine = Config::getEngine();
48
        self::$sqlHelper = Config::getSqlHelper();
49
    }
50
51
    public static function connect()
52
    {
53
        return self::$engine->connect();
54
    }
55
56
    public static function disconnect()
57
    {
58
        return self::$engine->disconnect();
0 ignored issues
show
Bug introduced by
The method disconnect() does not exist on Alxarafe\Database\Engine. Did you maybe mean connect()? ( Ignorable by Annotation )

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

58
        return self::$engine->/** @scrutinizer ignore-call */ disconnect();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
59
    }
60
61
    public static function connected()
62
    {
63
        return self::$engine->connected();
0 ignored issues
show
Bug introduced by
The method connected() does not exist on Alxarafe\Database\Engine. Did you maybe mean connect()? ( Ignorable by Annotation )

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

63
        return self::$engine->/** @scrutinizer ignore-call */ connected();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
64
    }
65
66
    public static function getDataTypes()
67
    {
68
        return self::$sqlHelper->getDataTypes();
69
    }
70
71
    /**
72
     * Ejecuta una sentencia SQL retornando TRUE si ha tenido éxito
73
     *
74
     * @author  Rafael San José Tovar <[email protected]>
75
     * @version 2022.0721
76
     *
77
     * @param string $query
78
     * @param array  $vars
79
     *
80
     * @return bool
81
     */
82
    public static function exec(string $query, array $vars = []): bool
83
    {
84
        return self::$engine->exec($query, $vars);
0 ignored issues
show
Unused Code introduced by
The call to Alxarafe\Database\Engine::exec() has too many arguments starting with $vars. ( Ignorable by Annotation )

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

84
        return self::$engine->/** @scrutinizer ignore-call */ exec($query, $vars);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
85
    }
86
87
    /**
88
     * Ejecuta una sentencia SELECT, retornando false si hay error, o un array
89
     * con el resultado de la consulta.
90
     *
91
     * @author  Rafael San José Tovar <[email protected]>
92
     * @version 2022.0721
93
     *
94
     * @param string $query
95
     * @param array  $vars
96
     *
97
     * @return array|false
98
     */
99
    public static function select(string $query, array $vars = [])
100
    {
101
        return self::$engine->select($query, $vars);
0 ignored issues
show
Unused Code introduced by
The call to Alxarafe\Database\Engine::select() has too many arguments starting with $vars. ( Ignorable by Annotation )

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

101
        return self::$engine->/** @scrutinizer ignore-call */ select($query, $vars);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
102
    }
103
104
    public static function getErrors()
105
    {
106
        return self::$engine->getErrors();
0 ignored issues
show
Bug introduced by
The method getErrors() does not exist on Alxarafe\Database\Engine. ( Ignorable by Annotation )

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

106
        return self::$engine->/** @scrutinizer ignore-call */ getErrors();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
107
    }
108
109
    public static function beginTransaction()
110
    {
111
        return self::$engine->beginTransaction();
112
    }
113
114
    public static function commit()
115
    {
116
        return self::$engine->commit();
117
    }
118
119
    public static function close()
120
    {
121
        return self::$engine->close();
0 ignored issues
show
Bug introduced by
The method close() does not exist on Alxarafe\Database\Engine. ( Ignorable by Annotation )

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

121
        return self::$engine->/** @scrutinizer ignore-call */ close();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
122
    }
123
124
    public static function rollback()
125
    {
126
        return self::$engine->rollback();
127
    }
128
129
    public static function version()
130
    {
131
        return self::$engine->server_info();
0 ignored issues
show
Bug introduced by
The method server_info() does not exist on Alxarafe\Database\Engine. ( Ignorable by Annotation )

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

131
        return self::$engine->/** @scrutinizer ignore-call */ server_info();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
132
    }
133
}
134