public function addClass(DOMElement &$element, $class)
    {
        if (empty($class)) {
            return $element;
        }

        // Normalize class
        $class = trim($class);
        if (empty($class)) {
            return $element;
        }

        // Get current class
        $currentClass = trim($this->attr($element, 'class'));

        // Check if class already exists
        $classes = explode(' ', $currentClass);
        if (in_array($class, $classes)) {
            return $element;
        }

        // Append new class
        $this->appendAttr($element, 'class', $class);

        // Return the DOM Element
        return $element;
    }
public function addClass(DOMElement &$element, $class)
    {
        if (empty($class)) {
            return $element;
        }

        // Normalize class
        $class = trim($class);
        if (empty($class)) {
            return $element;
        }

        // Get current class
        $currentClass = trim($this->attr($element, 'class'));

        // Check if class already exists
        $classes = explode(' ', $currentClass);
        if (in_array($class, $classes)) {
            return $element;
        }

        // Append new class
        $this->appendAttr($element, 'class', $class);

        // Return the DOM Element
        return $element;
    }
public function addClass ( DOMElement & $ element , $ class ) { if ( empty ( $ class ) ) { return $ element ; } // Normalize class $ class = trim ( $ class ) ; if ( empty ( $ class ) ) { return $ element ; } // Get current class $ currentClass = trim ( $ this -> attr ( $ element , 'class' ) ) ; // Check if class already exists $ classes = explode ( ' ' , $ currentClass ) ; if ( in_array ( $ class , $ classes ) ) { return $ element ; } // Append new class $ this -> appendAttr ( $ element , 'class' , $ class ) ; // Return the DOM Element return $ element ; }
Append a class to the DOMElement.

@param DOMElement $element The DOMElement to handle.
@param string     $class   The class name.

@return DOMElement
@throws Exception
Append a class to the DOMElement .