<?php
namespace Claromentis\Core\Config;

$GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"] = (@$GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"] ?: array()) + array("_ea8229a121285ee6" . "49a72fd880bac39b" => base64_decode("YXJyYXlfZ" . "mlsdGVy"), "_d155d43a39de93f858123c" . "6b6ce31d8a" => base64_decode("cHJlZ19tYXRj" . "aA=="), "_b936ec7b537428b0006df1" . "46fe45f21e" => base64_decode("L1wuY29uZ" . "mlnJC8="));
use ArrayAccess;
use ArrayIterator;
use Claromentis\Core\Config\Exception\NotFoundException;
use IteratorAggregate;
use Pimple\Container;






class ConfigRegistry implements ArrayAccess, IteratorAggregate
{
    protected Container $app;
    
    
    
    
    
    
    protected array $configs;
    public function __construct(Container $app)
    {
        $this->app = $app;
        $this->configs = [];
    }
    
    
    
    
    
    
    
    public function register(string $name, Config $config)
    {
        $this->configs[$name] = $config;
    }
    
    
    
    
    
    
    public function unregister(string $name)
    {
        unset($this->configs[$name]);
    }
    
    
    
    
    
    
    
    public function hasConfig(string $name) : bool
    {
        return isset($this->configs[$name]);
    }
    
    
    
    
    
    
    
    
    public function getConfig(string $name)
    {
        if (!$this->hasConfig($name)) {
            throw NotFoundException::configBundle($name);
        }
        return $this->configs[$name];
    }
    
    
    
    
    
    
    
    
    public function getAllConfigs() : array
    {
        $this->loadAllConfigServices();
        return $this->configs;
    }
    
    
    
    
    
    
    
    
    
    
    
    
    private function loadAllConfigServices() : void
    {
        $_7c9a0e71ab4bb12053b953d2b572d29c = $this->app->keys();
        $_bf00d81868c247ca58d1b157aaf1fed5 = $GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_ea8229a1" . "21285ee64" . "9a72fd880" . "bac39b"]($_7c9a0e71ab4bb12053b953d2b572d29c, function ($key) {
            return $GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_d155d43a39de93f858123c6b6ce31d8" . "a"]($GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_b936ec7b537428b0006df" . "146fe45f21e"], $key);
        });
        foreach ($_bf00d81868c247ca58d1b157aaf1fed5 as $_d4250c98cdbe7e3c0d14327314c47a07) {
            $this->app[$_d4250c98cdbe7e3c0d14327314c47a07];
        }
    }
    public function offsetExists($_1f50e30be8c2fefa6881834e71d504a2)
    {
        return $this->hasConfig($_1f50e30be8c2fefa6881834e71d504a2);
    }
    public function offsetGet($_1f50e30be8c2fefa6881834e71d504a2)
    {
        return $this->getConfig($_1f50e30be8c2fefa6881834e71d504a2);
    }
    public function offsetSet($_1f50e30be8c2fefa6881834e71d504a2, $value)
    {
        $this->register($_1f50e30be8c2fefa6881834e71d504a2, $value);
    }
    public function offsetUnset($_1f50e30be8c2fefa6881834e71d504a2)
    {
        $this->unregister($_1f50e30be8c2fefa6881834e71d504a2);
    }
    public function getIterator() : ArrayIterator
    {
        return new ArrayIterator($this->configs);
    }
}