<?php

class Connection {

    public static function connect(): PDO {
        try {
            $link = new PDO(
                "mysql:host=localhost;dbname=posystem;charset=utf8mb4",
                "root",
                ""
            );
            $link->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
            return $link;
        } catch (PDOException $e) {
            throw new RuntimeException(
                "Database connection failed: " . $e->getMessage(),
                0,
                $e
            );
        }
    }
}
