Conditions | 3 |
Paths | 4 |
Total Lines | 22 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 12 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
20 | protected function connectToServer(): PDO |
||
21 | { |
||
22 | $connection = new PDO( |
||
23 | sprintf('sqlsrv:server=%s;Database=%s;TrustServerCertificate=yes;', |
||
24 | $this->config->getLocation(), |
||
25 | $this->config->getDatabase() |
||
26 | ), |
||
27 | $this->config->getUser(), |
||
28 | $this->config->getPassword() |
||
29 | ); |
||
30 | |||
31 | $connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
||
32 | |||
33 | if ($this->config->isPersistent()) { |
||
34 | $connection->setAttribute(PDO::ATTR_PERSISTENT, true); |
||
35 | } |
||
36 | |||
37 | foreach ($this->attributes as $key => $value){ |
||
38 | $connection->setAttribute($key, $value); |
||
39 | } |
||
40 | |||
41 | return $connection; |
||
42 | } |
||
44 |