Test Failed
Push — main ( fac5ed...59bfee )
by Rafael
50:50
created

Database::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 6
rs 10
1
<?php
2
3
/* Copyright (C) 2024      Rafael San José      <[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
 * 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 DoliCore\Base;
20
21
use DebugBar\DebugBarException;
22
23
/**
24
 * Class Database
25
 *
26
 * This class is only needed for compatibility with Dolibarr.
27
 *
28
 * @package DoliCore\Base
29
 */
30
class Database extends \Alxarafe\Base\Database
31
{
32
    /**
33
     * It can be received as a database type, the name used in Dolibarr. For compatibility,
34
     * if the name used in Dolibarr is in the index (e.g. mysqli), the value will be used
35
     * (e.g. mysql).
36
     */
37
    private const DB_TYPES = [
38
        'mysqli' => 'mysql',
39
    ];
40
41
    /**
42
     * Construct the database access
43
     *
44
     * @param $db
45
     *
46
     * @throws DebugBarException
47
     */
48
    public function __construct($db)
49
    {
50
        if (isset(self::DB_TYPES[$db->type])) {
51
            $db->type = self::DB_TYPES[$db->type];
52
        }
53
        parent::__construct($db);
54
    }
55
}
56