ConnectionConfig   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 36
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A generateDsn() 0 8 1
A __construct() 0 3 1
A getAdapterConnectionClass() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace Janisbiz\LightOrm\Dms\MySQL\Connection;
4
5
use Janisbiz\LightOrm\Connection\AbstractConnectionConfig;
6
7
class ConnectionConfig extends AbstractConnectionConfig
8
{
9
    const ADAPTER = 'mysql';
10
11
    /**
12
     * @param string $host
13
     * @param string $username
14
     * @param string $password
15
     * @param string $dbname
16
     * @param int $port
17
     */
18
    public function __construct(string $host, string $username, string $password, string $dbname, int $port = 3306)
19
    {
20
        parent::__construct($host, $username, $password, $dbname, static::ADAPTER, $port);
21
    }
22
23
    /**
24
     * @return string
25
     */
26
    public function generateDsn(): string
27
    {
28
        return \sprintf(
29
            '%s:host=%s;dbname=%s;charset=utf8mb4;port=%d',
30
            $this->adapter,
31
            $this->host,
32
            $this->dbname,
33
            $this->port
34
        );
35
    }
36
37
    /**
38
     * @return string
39
     */
40
    public function getAdapterConnectionClass(): string
41
    {
42
        return Connection::class;
43
    }
44
}
45