Completed
Push — master ( 1b6594...be51ba )
by Agel_Nash
04:51
created

LegacyDatabase::__construct()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 25
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 25
ccs 12
cts 12
cp 1
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 11
nc 1
nop 9
crap 1

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php namespace AgelxNash\Modx\Evo\Database;
2
3
/**
4
 * @deprecated
5
 */
6
class LegacyDatabase extends AbstractDatabase
7
{
8
    /**
9
     * @param string $host
10
     * @param string $database
11
     * @param string $username
12
     * @param string $password
13
     * @param string $prefix
14
     * @param string $charset
15
     * @param string $method
16
     * @param string $collation
17
     * @param string $driver
18
     * @throws Exceptions\Exception
19
     */
20 3
    public function __construct(
21
        $host = '',
22
        $database = '',
23
        $username = '',
24
        $password = '',
25
        $prefix = '',
26
        $charset = 'utf8mb4',
27
        $method = 'SET CHARACTER SET',
28
        $collation = 'utf8mb4_unicode_ci',
29
        $driver = Drivers\MySqliDriver::class
30
    ) {
31 3
        $database = trim($database, '`');
32
33 3
        $this->setConfig(compact(
34 3
            'host',
35 3
            'database',
36 3
            'username',
37 3
            'password',
38 3
            'prefix',
39 3
            'charset',
40 3
            'method',
41 3
            'collation'
42
        ));
43
44 3
        $this->setDriver($driver);
45 3
    }
46
}
47