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();
    }
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();
    }
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 ( ) ; }
Check and return the Id of an Identifable Element

@param Identifiable $element Identifable element
@return string
Check and return the Id of an Identifable Element