<?php
namespace Claromentis\Core\Config;

$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"] ?: array()) + array("_b936ec7b537428b0006df146fe45f" . "21e" => base64_decode("L1wuY29uZmln" . "JC8="), "_d155d43a39de93f8" . "58123c6b6ce31d8a" => base64_decode("cHJlZ1" . "9tYXRj" . "aA=="), "_ea8229a121285ee649a7" . "2fd880bac39b" => base64_decode("YXJyYXlfZm" . "lsdGVy"));
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"]["_ea8229a121285ee649a72fd880ba" . "c39b"]($_7c9a0e71ab4bb12053b953d2b572d29c, function ($key) {
            return $GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_d155d43a39de93" . "f858123c6b6ce31" . "d8a"]($GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_b936ec7b537" . "428b0006df14" . "6fe45f21e"], $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);
    }
}