| Conditions | 5 |
| Paths | 8 |
| Total Lines | 19 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 5.025 |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | 280 | public function createConnection(): PDO |
|
| 13 | { |
||
| 14 | 280 | $this->attributes += [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]; |
|
| 15 | |||
| 16 | 280 | if (PHP_VERSION_ID >= 80100) { |
|
| 17 | $this->attributes += [PDO::ATTR_STRINGIFY_FETCHES => true]; |
||
| 18 | } |
||
| 19 | |||
| 20 | 280 | $pdo = parent::createConnection(); |
|
| 21 | |||
| 22 | 280 | if ($this->charset !== null) { |
|
| 23 | 1 | $pdo->exec('SET NAMES ' . $pdo->quote($this->charset)); |
|
| 24 | } |
||
| 25 | |||
| 26 | 280 | if (!str_contains($this->dsn, 'charset') && $this->charset === null) { |
|
| 27 | 1 | $pdo->exec('SET NAMES ' . $pdo->quote('utf8mb4')); |
|
| 28 | } |
||
| 29 | |||
| 30 | 280 | return $pdo; |
|
| 31 | } |
||
| 38 |