Passed
Push — master ( bd72d4...a51a38 )
by 世昌
02:21
created

MySQLConnector::applyConfig()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 3
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A MySQLConnector::getDsn() 0 3 1
1
<?php
2
namespace nebula\component\database\connector;
3
4
use nebula\component\database\exception\ConfigException;
5
6
/**
7
 * 连接器
8
 */
9
class MySQLConnector extends Connector
10
{
11
    protected static $type = 'mysql';
12
13
    protected $defaultConfig = [
14
        'database-prefix' => '',
15
        'database-name' => 'nebula',
16
        'database-user' => 'root',
17
        'database-password' => '',
18
        'server-host' => '127.0.0.1',
19
        'server-port' => 3306,
20
        'database-charset' => 'utf8mb4',
21
    ];
22
23
24
25
    /**
26
     * 获取PDO链接描述
27
     *
28
     * @return string
29
     */
30
    public function getDsn():string
31
    {
32
        return 'mysql:host='.$this->config['server-host'].';charset='.$this->config['database-charset'].';port='.$this->config['server-port'];
33
    }
34
35
    
36
}
37