<?php

namespace BWDK\Core;

class App
{
    protected static array $instances = [];

    public static function bind(string $abstract, $concrete): void
    {
        self::$instances[$abstract] = $concrete;
    }

    public static function get(string $abstract)
    {
        if (!isset(self::$instances[$abstract])) {
            throw new \Exception("Service {$abstract} not bound.");
        }

        return self::$instances[$abstract];
    }

    public static function has(string $abstract): bool
    {
        return isset(self::$instances[$abstract]);
    }
}
