Get the wrapped element as an enumerated type.

@throws \UnexpectedValueException If the element is not an enumerated
@return \ASN1\Type\Primitive\Enumerated
337043
public function asEnumerated(): Primitive\Enumerated
    {
        if (!$this->_element instanceof Primitive\Enumerated) {
            throw new \UnexpectedValueException(
                $this->_generateExceptionMessage(Element::TYPE_ENUMERATED));
        }
        return $this->_element;
    }
462473
public function getTemplate()
    {
        if (!$this->__template instanceof TemplateInterface)
        {
            //Make sure we have a template identifier
            if (!($this->__template instanceof ObjectIdentifier)) {
                $this->setTemplate($this->__template);
            }

            $options = array(
                'filters'   => $this->getConfig()->template_filters,
                'functions' => $this->getConfig()->template_functions,
            );

            $this->__template = $this->getObject($this->__template, $options);

            if(!$this->__template instanceof TemplateInterface)
            {
                throw new \UnexpectedValueException(
                    'Template: '.get_class($this->__template).' does not implement TemplateInterface'
                );
            }
        }

        return $this->__template;
    }
576479
protected function getMetaClass()
    {
        foreach ($this->builtInClasses as $model => $meta) {
            if ($this instanceof $model) {
                return $meta;
            }
        }

        throw new UnexpectedValueException(sprintf('%s must extends one of Corcel built-in models: Comment, Post, Term or User.', static::class));
    }
221285
public function getValueType()
	{
		$xmlType =SchemaTypes::getInstance()->getTypeForDOMNode( $this->domNode );
		// $xmlType = $this->types->getType( $this->domNode->localName, $this->domNode->prefix );
		if ( $xmlType )
		{
			$type = Type::XmlTypeToPHPType( $xmlType );
			if ( $type ) return $type;
		}
		return Type::string;
	}
827320
protected function byProperty()
    {
        $fields = $this->fieldIdentifiers();
        if (empty($fields)) {
            throw new UnexpectedValueException(
                'Property is required.'
            );
        }

        $dir = $this->direction();
        $dir = $dir === null ? '' : ' '.$dir;

        return implode($dir.', ', $fields).$dir;
    }
523138
public function getTypeValue()
    {
        return function($row) {
            $name = is_null($row->component_name) ? 'core' : $row->component_name;

            return '<span class="label-circle" data-color="' . component_color($name) . '" >' . ucfirst(Str::humanize($name)) . '</span>';
        };
    }
817740
public function asVideotexString(): Primitive\VideotexString
    {
        if (!$this->_element instanceof Primitive\VideotexString) {
            throw new \UnexpectedValueException(
                $this->_generateExceptionMessage(Element::TYPE_VIDEOTEX_STRING));
        }
        return $this->_element;
    }
352090
public function asCharacterString(): Primitive\CharacterString
    {
        if (!$this->_element instanceof Primitive\CharacterString) {
            throw new \UnexpectedValueException(
                $this->_generateExceptionMessage(Element::TYPE_CHARACTER_STRING));
        }
        return $this->_element;
    }
162684
public function asGraphicString(): Primitive\GraphicString
    {
        if (!$this->_element instanceof Primitive\GraphicString) {
            throw new \UnexpectedValueException(
                $this->_generateExceptionMessage(Element::TYPE_GRAPHIC_STRING));
        }
        return $this->_element;
    }
528210
protected function getSelectedValue()
    {
        $value = $this->getValueAttribute();
        if (!is_array($value) && !($value instanceof \Traversable)) {
            return $this->getOptionValueScalar($value);
        }
        $selectedValues = [];
        foreach ($value as $selectedValueElement) {
            $selectedValues[] = $this->getOptionValueScalar($selectedValueElement);
        }
        return $selectedValues;
    }
122542
public function toASN1(): StringType
    {
        switch ($this->_tag) {
            case Element::TYPE_IA5_STRING:
                return new IA5String($this->_text);
            case Element::TYPE_VISIBLE_STRING:
                return new VisibleString($this->_text);
            case Element::TYPE_BMP_STRING:
                return new BMPString($this->_text);
            case Element::TYPE_UTF8_STRING:
                return new UTF8String($this->_text);
            default:
                throw new \UnexpectedValueException(
                    "Type " . Element::tagToName($this->_tag) . " not supported.");
        }
    }
635266
public function getElement()
	{
		$element = $this->_element;

		if (empty($element))
		{
			$r = new ReflectionClass($this);
			if ($r->inNamespace())
			{
				$bits = explode('\\', __NAMESPACE__);

				// Should match either:
				//   Plugins\Folder\Element
				//   Components\Folder\Plugins\Element
				$element = strtolower($bits[2]);

				if (strtolower($bits[0]) == 'components')
				{
					$element = strtolower($bits[3]);
				}
			}
			else
			{
				throw new Exception('Cannot get or parse view class name.', 500);
			}
		}

		return $element;
	}
298056
public static function fromASN1(UnspecifiedType $el): self
    {
        switch ($el->tag()) {
            case Element::TYPE_OCTET_STRING:
            case Element::TYPE_UTF8_STRING:
                return new self($el->asString()->string(), $el->tag());
            case Element::TYPE_OBJECT_IDENTIFIER:
                return new self($el->asObjectIdentifier()->oid(), $el->tag());
        }
        throw new \UnexpectedValueException(
            "Type " . Element::tagToName($el->tag()) . " not supported.");
    }
36987
public function getBindingType()
    {
        $bindingType = $this->session->get(SessionParameter::BINDING_TYPE);

        if (!is_string($bindingType)) {
            return BindingType::cast(BindingType::CUSTOM);
        }

        try {
            return BindingType::cast($bindingType);
        } catch (InvalidEnumerationValueException $exception) {
            return BindingType::cast(BindingType::CUSTOM);
        }
    }
204141
public function asRelativeOID(): Primitive\RelativeOID
    {
        if (!$this->_element instanceof Primitive\RelativeOID) {
            throw new \UnexpectedValueException(
                $this->_generateExceptionMessage(Element::TYPE_RELATIVE_OID));
        }
        return $this->_element;
    }
533729
public function getAdapter()
    {
        if(!$this->_adapter instanceof KDatabaseAdapterInterface)
        {
            $this->_adapter = $this->getObject($this->_adapter);

            if(!$this->_adapter instanceof KDatabaseAdapterInterface)
            {
                throw new UnexpectedValueException(
                    'Adapter: '.get_class($this->_adapter).' does not implement KDatabaseAdapterInterface'
                );
            }
        }

        return $this->_adapter;
    }
832056
public function getExceptionHandler()
    {
        if(!$this->__exception_handler instanceof KExceptionHandlerInterface)
        {
            $this->__exception_handler = $this->getObject($this->__exception_handler);

            if(!$this->__exception_handler instanceof KExceptionHandler)
            {
                throw new UnexpectedValueException(
                    'Exception Handler: '.get_class($this->__exception_handler).' does not implement KExceptionHandlerInterface'
                );
            }
        }

        return $this->__exception_handler;
    }