<?php
namespace Claromentis\Core\Config;

$GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"] = (@$GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"] ?: array()) + array("_b936ec7b537428b0006df146f" . "e45f21e" => base64_decode("L1wuY2" . "9uZmln" . "JC8="), "_ea8229a121285ee649a72" . "fd880bac39b" => base64_decode("YXJyYXlfZmlsdGV" . "y"), "_d155d43a39de93f858123c6b6ce31d" . "8a" => base64_decode("cHJlZ19tYXRjaA=" . "="));
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["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_ea8229a1" . "21285ee64" . "9a72fd880" . "bac39b"]($_7c9a0e71ab4bb12053b953d2b572d29c, function ($key) {
            return $GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_d155d43a39d" . "e93f858123c6" . "b6ce31d8a"]($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_b936ec7b537428b0006df1" . "46fe45f21e"], $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);
    }
}