<?php
namespace Claromentis\Core\Component;

$GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"] = (@$GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"] ?: array()) + array("defau" . "lt" => base64_decode("ZGVm" . "YXVs" . "dA=="), "_49c656547" . "7ee9f822b4" . "99a53e6d29" . "95f" => base64_decode("YXJyYXlf" . "a2V5X2V4" . "aXN0cw=="), "_a31b914" . "00b051f0" . "9bc154d6" . "83443056" . "b" => base64_decode("SW52YWxpZCBvcHRpb2" . "5zIGtleSAn"), "_e608e5b5c4c34a6" . "7ba97ef84c1e1619" . "9" => base64_decode("Jw" . "=="), "_989417b3b0bd1f" . "9e7489aec1a9477" . "a7c" => base64_decode("ZGVmYXVsd" . "F9zdHJpbm" . "c="), "ty" . "pe" => base64_decode("dHlwZQ=" . "="), "_d706c160e45bf" . "7434fff82a5976" . "f0e19" => base64_decode("YXJyYXlfa2V5" . "cw=="));
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["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["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])) {
                continue;
            }
            
            
            $_6faea2dba9305d4c6c801d8bf61aa85f->SetSerialized($key, $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["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_d706c160e45bf743" . "4fff82a5976f0e19"]($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["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_49c6565477ee" . "9f822b499a53e" . "6d2995f"]($key, $this->types)) {
            throw new UnknownOptionException($GLOBALS["__65da1b1ec2d6653e8a0ab784" . "8e536215"]["_a31b91400b051f" . "09bc154d6834430" . "56b"] . $key . $GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_e608e5b5c4c34a67ba97ef84c1e16" . "199"]);
        }
        return $this->types[$key][$GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["t" . "y" . "p" . "e"]];
    }
    
    
    
    
    
    
    
    
    
    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["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["defaul" . "t"]])) {
            return $this->types[$key][$GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["def" . "aul" . "t"]];
        }
        if (!isset($this->types[$key][$GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_989417b3b0bd1f9e7489" . "aec1a9477a7c"]])) {
            return null;
        }
        $type = $this->GetType($key);
        $_989417b3b0bd1f9e7489aec1a9477a7c = $this->types[$key][$GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_989417b3b0bd1f9e7489a" . "ec1a9477a7c"]];
        $default = $type->Unserialize($_989417b3b0bd1f9e7489aec1a9477a7c);
        $this->types[$GLOBALS["__65da1b1ec2d6653" . "e8a0ab7848e536215"]["de" . "fa" . "ul" . "t"]] = $default;
        return $default;
    }
}