<?php
namespace app;

// for email

class app
{
    public static $db;

    public static function init_db()
    {
        try {
            self::$db = new \PDO('sqlite:' . $_ENV['SQLITE_DB']);
            self::$db->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
        } catch (\PDOException $e) {
            die("Database error: " . $e->getMessage());
        }
    }

    public static function sendJson($data, $status = 200)
    {
        http_response_code($status);
        header('Content-Type: application/json');
        echo json_encode($data);
        exit;
    }
}
