| Conditions | 4 |
| Paths | 8 |
| Total Lines | 19 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 4.128 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 39 | 840 | public function getDsn(): string |
|
| 40 | { |
||
| 41 | 840 | $dsn = "$this->driver:" . "host=$this->host" . ';' . "dbname=$this->dbname"; |
|
| 42 | |||
| 43 | 840 | if ($this->port !== null) { |
|
| 44 | 840 | $dsn .= ';' . "port=$this->port"; |
|
| 45 | } |
||
| 46 | |||
| 47 | 840 | $parts = []; |
|
| 48 | |||
| 49 | 840 | foreach ($this->options as $key => $value) { |
|
| 50 | $parts[] = "$key=$value"; |
||
| 51 | } |
||
| 52 | |||
| 53 | 840 | if (!empty($parts)) { |
|
| 54 | $dsn . ';' . implode(';', $parts); |
||
| 55 | } |
||
| 56 | |||
| 57 | 840 | return $dsn; |
|
| 58 | } |
||
| 65 |