Total Complexity | 6 |
Total Lines | 37 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
7 | class Mysql extends SQL |
||
8 | { |
||
9 | const DEFAULT_HOST = 'localhost'; |
||
10 | const DEFAULT_PORT = 3306; |
||
11 | |||
12 | public function __construct(ConfigInterface $config, string $collection) |
||
13 | { |
||
14 | parent::__construct($config, $collection); |
||
15 | $db_host = $this->getHost(); |
||
16 | $db_port = $this->getPort(); |
||
17 | $db_auth = $this->getAuth(); |
||
18 | $db_driv = $this->getConfig()->get('driver'); |
||
19 | $db_name = $this->getConfig()->get('database'); |
||
20 | |||
21 | $dsn = "$db_driv://$db_auth$db_host:$db_port/$db_name"; |
||
22 | |||
23 | $this->setDsn($dsn); |
||
24 | } |
||
25 | |||
26 | private function getHost(): string |
||
30 | } |
||
31 | |||
32 | private function getPort(): int |
||
33 | { |
||
34 | $port = $this->getConfig()->get('port'); |
||
35 | return $port ?? self::DEFAULT_PORT; |
||
36 | } |
||
37 | |||
38 | private function getAuth(): string |
||
44 | } |
||
45 | |||
46 | } |
||
47 |