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

MySQLConnector::getDsn()   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
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