Parse from ASN.1.

@param TaggedType $el
@throws \UnexpectedValueException
@return self
356255
public static function fromASN1(TaggedType $el): self
    {
        switch ($el->tag()) {
            case self::TYPE_NAME:
                return TargetName::fromChosenASN1($el->asExplicit()->asTagged());
            case self::TYPE_GROUP:
                return TargetGroup::fromChosenASN1(
                    $el->asExplicit()->asTagged());
            case self::TYPE_CERT:
                throw new \RuntimeException("targetCert not supported.");
        }
        throw new \UnexpectedValueException(
            "Target type " . $el->tag() . " not supported.");
    }
670277
protected function parseItem()
    {
        if (null === ($primary = $this->parse('Primary', null))) {
            return $this;
        }
        
        switch ($this->type) {
            case '?':
            case '*':
            case '+':
                return new AST\Item($primary, $this->consume());
        }
        
        return $primary;
    }
101791
public function asApplication(): Tagged\ApplicationType
    {
        if (!$this->_element instanceof Tagged\ApplicationType) {
            throw new \UnexpectedValueException(
                "Application type expected, got " .
                $this->_typeDescriptorString());
        }
        return $this->_element;
    }
1258754
public static function fromASN1(TimeType $el): self
    {
        $obj = new self($el->dateTime());
        $obj->_type = $el->tag();
        return $obj;
    }
345183
protected function parseType(DOMElement $element, $flagRequired = true)
    {
        if ($flagRequired || (!$flagRequired && $element->hasAttribute('type'))) {
            $this->type = XmlUtil::getRequiredAttributeValue($element, 'type');
        }
    }
421758
public function asTime(): TimeType
    {
        if (!$this->_element instanceof TimeType) {
            throw new \UnexpectedValueException(
                $this->_generateExceptionMessage(Element::TYPE_TIME));
        }
        return $this->_element;
    }
593
protected function parseArgs(DOMElement $element)
    {
        $args = XmlUtil::getChildElements($element, 'arg');
        foreach ($args as $arg) {
            $name = XmlUtil::getRequiredAttributeValue($arg, 'name');
            $this->args[$name] = XmlUtil::getText($arg);
        }
    }
1319486
public function setStringValue($stringValue)
    {
        if (\is_array($stringValue) || \is_object($stringValue)) {
            $m = "Invalid value type for attribute {$this->getFamilyCode()}.{$this->getAttributeCode()}, ";
            $m .= 'expecting string, got '.gettype($stringValue);
            throw new \UnexpectedValueException($m);
        }
        if (null !== $stringValue && 255 < \mb_strlen($stringValue)) {
            $stringValue = mb_substr($stringValue, 0, 255);
        }
        $this->stringValue = null === $stringValue ? null : (string) $stringValue;

        return $this;
    }
174301
public static function fromElementBase(ElementBase $el): self
    {
        // if element is already wrapped
        if ($el instanceof self) {
            return $el;
        }
        return new self($el->asElement());
    }
1161310
public function asInteger(): Primitive\Integer
    {
        if (!$this->_element instanceof Primitive\Integer) {
            throw new \UnexpectedValueException(
                $this->_generateExceptionMessage(Element::TYPE_INTEGER));
        }
        return $this->_element;
    }
532282
public static function tags( $element, $attribs = null, $contents ) {
		return self::openElement( $element, $attribs ) . $contents . "</$element>";
	}
201271
public static function fromASN1(Sequence $seq): self
    {
        $version = $seq->at(0)
            ->asInteger()
            ->intNumber();
        if (!in_array($version, [self::VERSION_1, self::VERSION_2])) {
            throw new \UnexpectedValueException(
                "Version $version not supported.");
        }
        $algo = AlgorithmIdentifier::fromASN1($seq->at(1)->asSequence());
        $key = $seq->at(2)
            ->asOctetString()
            ->string();
        // @todo parse attributes and public key
        $obj = new static($algo, $key);
        $obj->_version = $version;
        return $obj;
    }
639495
def tag_from_element(el):
    
    tag = el.tag
    namespace = None
    if tag.startswith('{'):
        # Strip namespace of the form "{namespace}tag"
        namespace,tag = tag[1:].split('}')
    try:
        cls = globals()[tag.title()]
        if not issubclass(cls, TagBase):
            raise KeyError()
    except KeyError:
        raise ValueError("TagBase doesn't have a subclass for '%s'." % tag)
    children = [tag_from_element(c) for c in el]
    tag = cls(*children, **el.attrib)
    tag.text = el.text
    tag.tail = el.tail
    if namespace:
        tag.attrib['xmlns'] = namespace
    return tag
337043
public function asEnumerated(): Primitive\Enumerated
    {
        if (!$this->_element instanceof Primitive\Enumerated) {
            throw new \UnexpectedValueException(
                $this->_generateExceptionMessage(Element::TYPE_ENUMERATED));
        }
        return $this->_element;
    }
1144162
public function withAppended(Element $el): self
    {
        $obj = clone $this;
        array_push($obj->_elements, $el);
        return $obj;
    }
649714
public function parsedownElement($title = null, $alt = null, $class = null, $id = null, $reset = true)
    {
        return $this->bubble('parsedownElement', [$title, $alt, $class, $id, $reset]);
    }
1153894
public function taggedAll( $beanType, $tagList ) {
		if ($tagList!==false && !is_array($tagList)) $tags = explode( ",", (string)$tagList); else $tags=$tagList;
		$beans = array();
		foreach($tags as $tag) {
			$beans = $this->tagged($beanType,$tag);
			if (isset($oldBeans)) $beans = array_intersect_assoc($beans,$oldBeans);
			$oldBeans = $beans;
		}
		return $beans;
	}