<?php

declare(strict_types=1);

$host = (string) iav_env('DB_HOST', 'localhost');
$port = (int) iav_env('DB_PORT', 3306);
$name = (string) iav_env('DB_NAME', 'instantaivirtuals');
$charset = (string) iav_env('DB_CHARSET', 'utf8mb4');

return [
    'driver' => 'mysql',
    'host' => $host,
    'port' => $port,
    'database' => $name,
    'username' => (string) iav_env('DB_USER', ''),
    'password' => (string) iav_env('DB_PASS', ''),
    'charset' => $charset,
    'collation' => 'utf8mb4_unicode_ci',
    'dsn' => sprintf('mysql:host=%s;port=%d;dbname=%s;charset=%s', $host, $port, $name, $charset),
    'options' => [
        PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
        PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
        PDO::ATTR_EMULATE_PREPARES => false,
        PDO::ATTR_STRINGIFY_FETCHES => false,
        PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES {$charset} COLLATE utf8mb4_unicode_ci",
    ],
];
