| Total Complexity | 6 |
| Total Lines | 56 |
| Duplicated Lines | 0 % |
| Coverage | 89.47% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | final class Dsn |
||
| 8 | { |
||
| 9 | private ?string $dbname; |
||
| 10 | private string $driver; |
||
| 11 | private ?string $host; |
||
| 12 | private ?string $port; |
||
| 13 | private array $options; |
||
| 14 | |||
| 15 | 840 | public function __construct(string $driver, string $host, string $dbname, string $port = null, array $options = []) |
|
| 22 | 840 | } |
|
| 23 | |||
| 24 | /** |
||
| 25 | * @return string the Data Source Name, or DSN, contains the information required to connect to the database. |
||
| 26 | * Please refer to the [PHP manual](http://php.net/manual/en/pdo.construct.php) on the format of the DSN string. |
||
| 27 | * |
||
| 28 | * The `driver` array key is used as the driver prefix of the DSN, all further key-value pairs are rendered as |
||
| 29 | * `key=value` and concatenated by `;`. For example: |
||
| 30 | * |
||
| 31 | * ```php |
||
| 32 | * $dsn = new Dsn('mysql', '127.0.0.1', 'yiitest', '3306'); |
||
| 33 | * $connection = new Connection($this->cache, $this->logger, $this->profiler, $dsn->getDsn()); |
||
| 34 | * ``` |
||
| 35 | * |
||
| 36 | * Will result in the DSN string `mysql:host=127.0.0.1;dbname=yiitest;port=3306`. |
||
| 37 | */ |
||
| 38 | |||
| 39 | 840 | public function getDsn(): string |
|
| 58 | } |
||
| 59 | |||
| 60 | 2 | public function getDriver(): string |
|
| 65 |