<?php
declare(strict_types=1);
namespace App\Core;

final class Container {
    private array $instances = [];

    public function get(string $id): mixed {
        if (isset($this->instances[$id])) return $this->instances[$id];
        $this->instances[$id] = match ($id) {
            Database::class => Database::instance(),
            SessionAuth::class => new SessionAuth(),
            default => new $id(),
        };
        return $this->instances[$id];
    }
}
