<?php

class Connection
{
    private $env;

    public function __construct()
    {
        $this->env = parse_ini_file(__DIR__ . '/.env');
    }

    public function getConnection()
    {
        $dsn = "mysql:host=" . $this->env['HOST_NAME'] . ";dbname=" . $this->env['DATABASE'] . ";charset=utf8mb4";
        $pdo = new PDO($dsn, $this->env['USER'], $this->env['PASSWORD']);
        $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

        return $pdo;
    }
}
