Total Complexity | 4 |
Total Lines | 42 |
Duplicated Lines | 0 % |
Coverage | 66.67% |
Changes | 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 | 408 | public function asString(): string |
|
39 | } |
||
40 | |||
41 | public function __toString(): string |
||
42 | { |
||
43 | return $this->asString(); |
||
44 | } |
||
45 | |||
46 | public function getDriver(): string |
||
49 | } |
||
50 | } |
||
51 |