| Total Complexity | 5 |
| Total Lines | 48 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | final class Dsn |
||
| 8 | { |
||
| 9 | private string $databaseName; |
||
| 10 | private string $driver; |
||
| 11 | private string $server; |
||
| 12 | private string $port; |
||
| 13 | |||
| 14 | 408 | public function __construct(string $driver, string $server, string $databaseName, string $port = '1433') |
|
| 20 | 408 | } |
|
| 21 | |||
| 22 | /** |
||
| 23 | * @return string the Data Source Name, or DSN, contains the information required to connect to the database. |
||
| 24 | * Please refer to the [PHP manual](http://php.net/manual/en/pdo.construct.php) on the format of the DSN string. |
||
| 25 | * |
||
| 26 | * The `driver` array key is used as the driver prefix of the DSN, all further key-value pairs are rendered as |
||
| 27 | * `key=value` and concatenated by `;`. For example: |
||
| 28 | * |
||
| 29 | * ```php |
||
| 30 | * $dsn = new MssqlDsn('sqlsrv', 'localhost', 'yiitest', '1433'); |
||
| 31 | * $connection = new MssqlConnection($this->cache, $this->logger, $this->profiler, $dsn->asString()); |
||
| 32 | * ``` |
||
| 33 | * |
||
| 34 | * Will result in the DSN string `sqlsrv:Server=localhost,1433;Database=yiitest`. |
||
| 35 | */ |
||
| 36 | public function asString(): string |
||
| 45 | } |
||
| 46 | |||
| 47 | public function __toString(): string |
||
| 48 | { |
||
| 49 | return $this->asString(); |
||
| 50 | } |
||
| 51 | |||
| 52 | public function getDriver(): string |
||
| 55 | } |
||
| 56 | } |
||
| 57 |