Conditions | 1 |
Paths | 1 |
Total Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 4 |
CRAP Score | 1 |
Changes | 0 |
1 | <?php |
||
15 | 1 | public function createPdo(string $dsn, string $username = null, string $password = null, array $options = []): PDO |
|
16 | { |
||
17 | $defaultPdoOptions = [ |
||
18 | 1 | PDO::ATTR_TIMEOUT => 5, |
|
19 | // We want emulation by default (faster for single queries). Disable if you want to |
||
20 | // use proper native prepared statements |
||
21 | PDO::ATTR_EMULATE_PREPARES => true, |
||
22 | PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, |
||
23 | PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, |
||
24 | ]; |
||
25 | |||
26 | 1 | $pdoOptions = $defaultPdoOptions + $options; |
|
27 | |||
28 | 1 | return new PDO($dsn, $username, $password, $pdoOptions); |
|
29 | } |
||
30 | } |
||
31 |