<?php
namespace Claromentis\Core\Config;

$GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"] = (@$GLOBALS["__65da1b1ec2d665" . "3e8a0ab7848e5362" . "15"] ?: array()) + array("_ea8229a1212" . "85ee649a72fd" . "880bac39b" => base64_decode("YXJy" . "YXlf" . "Zmls" . "dGVy"), "_b936ec7b5374" . "28b0006df146f" . "e45f21e" => base64_decode("L1wuY29u" . "ZmlnJC8="), "_d155d43a39de93f858123c6b6ce31d8" . "a" => base64_decode("cHJlZ19tYXR" . "jaA=="));
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["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_ea8229a121285ee649a72fd880bac39" . "b"]($_7c9a0e71ab4bb12053b953d2b572d29c, function ($key) {
            return $GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_d155d43a39de93f858123c6b6ce31" . "d8a"]($GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_b936ec7b537428b0" . "006df146fe45f21e"], $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);
    }
}