Check and return the Id of an Identifable Element

@param Identifiable $element Identifable element
@return string
439168
public static function check(Identifiable $element)
    {
        $elementId = $element->getId();

        if (!$elementId) {
            $element->setId(new static());
            return $element->getId();
        }

        $dangerousCharacters = array(' ', '|', PHP_EOL);
        $danger              = false;
        foreach ($dangerousCharacters as $dangerousCharacter) {
            if (stripos($elementId, $dangerousCharacter) !== false) {
                $danger = true;
                break;
            }
        }

        if ($danger) {
            trigger_error("Don't use special characters in IDs, they might cause problems! Stripping them for you...");
            $elementId = str_ireplace($dangerousCharacters, '', $elementId);
            $element->setId($elementId);
        }

        return $element->getId();
    }
376146
public static function getID($request)
    {
        if ($request instanceof DOMDocument) {
            $dom = $request;
        } else {
            $dom = new DOMDocument();
            $dom = OneLogin_Saml2_Utils::loadXML($dom, $request);
        }

        $id = $dom->documentElement->getAttribute('ID');
        return $id;
    }
368267
private function renderElement(Element $element) : string
    {
        $label = $element->getLabel();

        if ($label->isEmpty()) {
            return $element->render();
        }

        return $label->render() . $element->render();
    }
633610
protected function getIndexKey($element)
    {
        $key = $element->getFullyQualifiedStructuralElementName();

        // properties should have an additional $ before the property name
        if ($element instanceof PropertyInterface) {
            list($fqcn, $propertyName) = explode('::', $key);
            $key = $fqcn . '::$' . $propertyName;
        }

        return $key;
    }
629888
public function getID()
    {
        $idAttribute = $this->idAttribute;
        return (is_string($idAttribute) && !empty($idAttribute)) ? $this->$idAttribute : null;
    }
111207
public function generateElementId(Element $element) : string
    {
        preg_match('/^([a-zA-Z0-9]*)/', $element->getName(), $matches);
        $name = $matches[0];

        if (! isset($this->ids[$name])) {
            $this->ids[$name] = 0;
        }

        return $this->getId() . '-' . $name . '-' . $this->ids[$name]++;
    }
991202
public static function classIdentifierByID( $id )
    {
        $identifierHash = array_flip( self::classIdentifiersHash() );

        if ( isset( $identifierHash[$id] ) )
            return $identifierHash[$id];
        else
            return false;
    }
34408
public static function getTagByHandle($element)
    {
        $group = Craft::$app->tags->getTagGroupByHandle($element['group']);
        if ($group) {

            $query = Tag::find();
            $query->groupId($group->id);
            $query->slug($element['slug']);
            $tag = $query->one();

            if ($tag) {
                return $tag;
            }
        }
    }
844821
protected function getMethodNameForClass(Element $element)
    {
        // if a method exists for this element, then use that one
        $className = get_class($element);

        // strip namespaces;
        $className = substr($className, strrpos($className, '\\') + 1);

        // make first char lower case
        return strtolower(substr($className, 0, 1)) . substr($className, 1);
    }
175745
public function getValidationMessageFor($element)
    {
        $errorLabel = $this->getElement($element)->getParent()->find('css', '.sylius-validation-error');

        if (null === $errorLabel) {
            throw new ElementNotFoundException(
                $this->getSession(),
                'Validation message', 'css', '.sylius-validation-error')
            ;
        }

        return $errorLabel->getText();
    }
1197656
private function elementBodyAttr(string $element) : string
    {
        if (in_array($element, $this->body_elements) === true) {
            $attr = '';

            if (count($this->body_attr[$element]) > 0) {
                if (array_key_exists($element, $this->body_attr_first) === false) {
                    $attr = ' style="' . implode(' ', $this->body_attr[$element]) . '"';
                } else {
                    $attr = ' style="';
                    foreach ($this->body_attr[$element] as $body_attr) {
                        if (array_key_exists($body_attr, $this->body_attr_first[$element]) === false) {
                            $attr .= ' ' . $body_attr . ';';
                        } else {
                            if ($this->body_attr_first[$element][$body_attr] === true) {
                                $attr .= ' ' . $body_attr . ';';
                                $this->body_attr_first[$element][$body_attr] = false;
                            }
                        }
                    }
                    $attr .= '"';
                }
            }

            return $attr;
        } else {
            return '';
        }
    }
997142
public function identifier($identifier = null)
    {
        if (null === $identifier) {
            return $this->identifier;
        }

        $this->identifier = $identifier;
        return $this;
    }
1062036
protected function serializeElement($element)
	{
		return (is_array($element)) ? $this->serializeStrings($element) : $this->serializeLiteral($element);
	}
911324
def _element_get_id(self, element):
        
        if self._reader._level > 1:
            entry_id = element.get('id')
        else:
            entry_id = element.get('name')
        return entry_id
886118
public function getEntityForElement( $element )
	{
		if ( isset( $element['contextRef'] ) )
		{
			return $this->contexts[ $element['contextRef'] ]['entity']['identifier']['value'];
		}

		if ( isset( $element['tuple_elements'] ) )
		{
			foreach ( $element['tuple_elements'] as $elementKey => $tuple_elements )
			{
				foreach ( $tuple_elements as $tupleIndex => $tuple_element )
				{
					$result = $this->getEntityForElement( $tuple_element );
					if ( $result ) return $result;
				}
			}
		}

		throw new Exception( "The element '{$element['taxonomy_element']['id']}' has no context ref but also has no tuple members (getEntityForElement)" );
	}
962336
public function &getElementById( $id )
	{
		$id = urldecode( $id );

		$fragment = parse_url( $id, PHP_URL_FRAGMENT );
		$fragment = $fragment ? $fragment : $id;

		if ( ! isset( $this->elementIndex[ $fragment ] ) )
		{
			$false = false;
			return $false;
		}
		$element = &$this->elementIndex[ $fragment ];
		return $element;
	}
41338
public function indexOf( AbstractElement $element ) {
		$search_result = array_search($element, $this->childElements, true);

		return $search_result === false ? null : $search_result;
	}