Conditions | 1 |
Paths | 1 |
Total Lines | 25 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 1 |
Changes | 0 |
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; |
||
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 | } |
|
47 |