<?php
namespace Claromentis\Core\Config;

$GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"] = (@$GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"] ?: array()) + array("_ea8229a121285ee64" . "9a72fd880bac39b" => base64_decode("YXJyYX" . "lfZmls" . "dGVy"), "_d155d43a39de93f" . "858123c6b6ce31d8" . "a" => base64_decode("cHJlZ19tYXR" . "jaA=="), "_b936ec7b53" . "7428b0006df" . "146fe45f21e" => base64_decode("L1wuY29uZmln" . "JC8="));
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["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_ea8229a121285ee649a72fd880ba" . "c39b"]($_7c9a0e71ab4bb12053b953d2b572d29c, function ($key) {
            return $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_d155d43a39de93f858123c6b6ce31" . "d8a"]($GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_b936ec7b537428b" . "0006df146fe45f21" . "e"], $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);
    }
}