<?php
namespace Claromentis\Core\Component;

$GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"] = (@$GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"] ?: array()) + array("_a31b91400b051f09bc154d68" . "3443056b" => base64_decode("SW52YWxpZCBvcHRpb2" . "5zIGtleSAn"), "_70979d2" . "87fa2c98" . "d21aa078" . "34c259a5" . "2" => base64_decode("c3RydG9sb3" . "dlcg=="), "_f61cbfe" . "09f83985" . "4b95117f" . "e13b4a1b" . "a" => base64_decode("c3R" . "ycG" . "9z"), "_eba32e53b2b46e6443f307" . "2f9bb42f07" => base64_decode("ZGF0YS0" . "="), "_d706c160e45bf7434fff82a597" . "6f0e19" => base64_decode("YXJyYXl" . "fa2V5cw" . "=="), "t" . "y" . "p" . "e" => base64_decode("dHlwZ" . "Q=="), "_989417b3b0bd1f9e7489aec1a9477a7" . "c" => base64_decode("ZGVmYXVsdF9zdHJ" . "pbmc="), "_49c6565477ee9f" . "822b499a53e6d29" . "95f" => base64_decode("YXJyYXlfa2V5X2V4aXN0" . "cw=="), "de" . "fa" . "ul" . "t" => base64_decode("ZGVmY" . "XVsdA" . "=="), "_cfe3120f54395b67065" . "2b38c2d0a8e88" => base64_decode("c3Vic" . "3Ry"), "_e608e5b5c4c34a67ba9" . "7ef84c1e16199" => base64_decode("J" . "w" . "=" . "="));
use Claromentis\Core\Component\Exception\UnknownOptionException;
use Claromentis\Core\Component\ValueType\ValueType;
use Claromentis\Core\Component\ValueType\ValueTypeFactory;




class ValidatingOptions implements OptionsInterface
{
    protected $types = [];
    protected $values = [];
    
    
    
    
    
    
    
    
    
    
    public function __construct(array $_611d4f00b5d81631c8a2f6e92983631f = [], array $values = [])
    {
        foreach ($_611d4f00b5d81631c8a2f6e92983631f as $option_name => $_2eb87be11ba86628b66da5659d96a5e0) {
            
            
            $_2eb87be11ba86628b66da5659d96a5e0[$GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["ty" . "pe"]] = ValueTypeFactory::Create($_2eb87be11ba86628b66da5659d96a5e0);
            
            
            $this->types[$option_name] = $_2eb87be11ba86628b66da5659d96a5e0;
        }
        foreach ($values as $name => $value) {
            if (!isset($this->types[$name])) {
                continue;
            }
            
            
            
            $this->values[$name] = $this->GetType($name)->Normalize($value);
        }
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    public static function CreateFromSerialized($_611d4f00b5d81631c8a2f6e92983631f, $attributes)
    {
        $_6faea2dba9305d4c6c801d8bf61aa85f = new static($_611d4f00b5d81631c8a2f6e92983631f);
        foreach ($attributes as $key => $value) {
            
            
            if (isset($_6faea2dba9305d4c6c801d8bf61aa85f->types[$key])) {
                $_6faea2dba9305d4c6c801d8bf61aa85f->SetSerialized($key, $value);
                continue;
            }
            if ($GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_f61cbfe09" . "f839854b95" . "117fe13b4a" . "1ba"]($key, $GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"]["_eba32e53b2b46e6443f3072f9bb42" . "f07"]) === false) {
                continue;
            }
            
            
            $_86469bf8bbc51b3172aec04497466913 = $GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_70979d287fa2c98d21" . "aa07834c259a52"]($GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_cfe3120f54395b670652b38c2d0" . "a8e88"]($key, 5));
            foreach ($_6faea2dba9305d4c6c801d8bf61aa85f->types as $type => $_6aead4bff5639b251aebcf8a630e43a7) {
                if ($GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_70979d287fa2c98d2" . "1aa07834c259a52"]($type) === $_86469bf8bbc51b3172aec04497466913) {
                    $_6faea2dba9305d4c6c801d8bf61aa85f->SetSerialized($type, $value);
                }
            }
        }
        return $_6faea2dba9305d4c6c801d8bf61aa85f;
    }
    public function Get($name)
    {
        if (!isset($this->types[$name])) {
            return null;
        }
        
        
        if (isset($this->values[$name])) {
            return $this->values[$name];
        }
        return $this->GetDefault($name);
    }
    
    
    
    
    
    
    public function GetAll()
    {
        $_1f24efd4735b7a11b391147435e7d35d = [];
        foreach ($this->GetKeys() as $key) {
            $_1f24efd4735b7a11b391147435e7d35d[$key] = $this->Get($key);
        }
        return $_1f24efd4735b7a11b391147435e7d35d;
    }
    public function GetKeys()
    {
        return $GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_d706c16" . "0e45bf74" . "34fff82a" . "5976f0e1" . "9"]($this->types);
    }
    
    
    
    
    
    
    
    
    
    public function IsDefault($key)
    {
        if (!isset($this->values[$key])) {
            return true;
        }
        $value = $this->Get($key);
        $default = $this->GetDefault($key);
        return $default === $value;
    }
    
    
    
    
    
    
    
    
    
    public function GetType($key)
    {
        if (!$GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_49c6565477" . "ee9f822b499" . "a53e6d2995f"]($key, $this->types)) {
            throw new UnknownOptionException($GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_a31b91400b051f09bc154d" . "683443056b"] . $key . $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_e608e5b5c4c34a67ba" . "97ef84c1e16199"]);
        }
        return $this->types[$key][$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["ty" . "pe"]];
    }
    
    
    
    
    
    
    
    
    
    public function GetSerialized($key)
    {
        $type = $this->GetType($key);
        return $type->Serialize($this->Get($key));
    }
    protected function SetSerialized($key, $_d957779c7daa148ba3e831d162d15722)
    {
        $type = $this->GetType($key);
        $this->values[$key] = $type->Unserialize($_d957779c7daa148ba3e831d162d15722);
    }
    
    
    
    
    
    
    
    public function GetDefault($key)
    {
        if (isset($this->types[$key][$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["def" . "aul" . "t"]])) {
            return $this->types[$key][$GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["defaul" . "t"]];
        }
        if (!isset($this->types[$key][$GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_989417b3b0bd1f9e7489aec1a9" . "477a7c"]])) {
            return null;
        }
        $type = $this->GetType($key);
        $_989417b3b0bd1f9e7489aec1a9477a7c = $this->types[$key][$GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_989417b3b0" . "bd1f9e7489a" . "ec1a9477a7c"]];
        $default = $type->Unserialize($_989417b3b0bd1f9e7489aec1a9477a7c);
        $this->types[$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["defaul" . "t"]] = $default;
        return $default;
    }
}