Add CSS class to element. Previously added classes are not affected.
Multiple CSS classes can also be added if passed as space separated
string or array of class names.

@param string|array $class CSS class name or array of class names

@return $this
173239
public function addClass($class)
    {
        if (is_array($class)) {
            $class = implode(' ', $class);
        }

        if (!$this->class) {
            $this->class = [];
        }

        if (is_string($this->class)) {
            throw new Exception(['Property $class should always be array', 'object' => $this, 'class' => $this->class]);
        }

        $this->class = array_merge($this->class, explode(' ', $class));

        return $this;
    }
849405
public static function removeCssClass(&$options, $class)
    {
        if (isset($options['class'])) {
            $classes = array_unique(preg_split('/\s+/', $options['class'] . ' ' . $class, -1, PREG_SPLIT_NO_EMPTY));
            if (($index = array_search($class, $classes)) !== false) {
                unset($classes[$index]);
            }
            if (empty($classes)) {
                unset($options['class']);
            } else {
                $options['class'] = implode(' ', $classes);
            }
        }
    }
675661
protected function addClass($cssClass, &$attributes)
    {
        $class = array_get($attributes, 'class', '');
        if (!str_contains($class, $cssClass)) {
            $class .= ' ' . $cssClass;
        }
        return array_set($attributes, 'class', $class);
    }
811339
public function css( $cssClasses )
    {
        if ( ! $cssClasses )
        {
            return $this;
        }

        $cssClasses = explode( ' ', $cssClasses );

        foreach ( $cssClasses as $cssClass )
        {
            if ( $cssClass && false === in_array( $cssClass, $this->cssClasses ) )
            {
                $this->cssClasses[] = $cssClass;
            }
        }

        return $this;
    }
226679
public function addClass( string $class ): Tag
    {

        if ( ! isset( $this->attributes['class'] ) ) {
            $this->attributes['class'] = $class;
        } else {
            $this->attributes['class'] .= " $class";
        }

        return $this;
    }
1249933
public function addClass(&$class)
    {
        if (isset($this->_classes[$class->name()])) {
            $phpdoctor =& $this->_root->phpdoctor();
            echo "\n";
            $phpdoctor->warning('Found class '.$class->name().' again, overwriting previous version');
        }
        $this->_classes[$class->name()] =& $class;
    }
318954
public function setClass($class)
    {
        foreach ($this->results as $name) {
            $this->columns->offsetGet($name)->setClass($class);
        }
    }
1330221
def add_class(self, cssclass):
        """"""
        if self.has_class(cssclass):
            return self
        return self.toggle_class(cssclass)
369350
public function add_class( $class ) {
		if ( !isset( $this->attr['class'] ) || !is_array( $this->attr['class'] ) ) {
			$this->_sanitize_class();
		}
		if ( strpos( $class, ' ' ) !== false ) {
			$class = explode( ' ', $class );
		}
		if ( is_string( $class ) ) {
			$class = array( $class );
		}
		foreach ( $class as $c ) {
			$this->attr['class'][] = $c;
		}
		return $this;
	}
1007849
public function addClass(string $class): self
    {
        $classes = explode(' ', $class);

        foreach ($classes as $class) {
            if (!in_array($class, $this->rowClasses)) {
                $this->rowClasses[] = $class;
            }
        }

        return $this;
    }
464107
public function addClass($class)
    {
        if (!is_array($class)) {
            $class = preg_split('/\s+/', $class, null, PREG_SPLIT_NO_EMPTY);
        }
        $curClass = preg_split('/\s+/', $this->getAttribute('class'),
                               null, PREG_SPLIT_NO_EMPTY);
        foreach ($class as $c) {
            if (!in_array($c, $curClass)) {
                $curClass[] = $c;
            }
        }
        $this->setAttribute('class', implode(' ', $curClass));

        return $this;
    }
656937
public function setClass($class = '')
    {
        if (is_string($class) && (empty($class) === true || Format::isClass($class) === true)) {
            $class = trim($class);
            $this->class = $class;
        } else {
            $msg = "The 'class' argument must be a valid class name, '" . $class . "' given";
            throw new InvalidArgumentException($msg);
        }
    }
1162203
public function addClass ($class)
    {
        $targetArray = &$this->customClasses;
        if (!is_array($class))
            $targetArray[] = $class;
        else
            $targetArray = array_merge($targetArray, $class);
        return $this;
    }
1068799
public function removeCssClass($cssClass)
    {
        if (array_key_exists($cssClass, $this->cssClasses)) {
            unset($this->cssClasses[$cssClass]);
        }
        return $this;
    }
546161
public function addClass($name)
    {
        foreach ($this as $node) {
            if ($node instanceof \DOMElement) {
                /** @var \DOMElement $node */
                $classes = preg_split('/\s+/s', $node->getAttribute('class'));
                $found = false;
                $count = count($classes);
                for ($i = 0; $i < $count; $i++) {
                    if ($classes[$i] == $name) {
                        $found = true;
                    }
                }
                if (!$found) {
                    $classes[] = $name;
                    $node->setAttribute('class', trim(join(' ', $classes)));
                }
            }
        }
        return $this;
    }
539727
public function removeClass(DOMElement &$element, $class)
    {
        // Get current class
        $currentClass = trim($this->attr($element, 'class'));

        // Check if class doesn't exists
        $classes = explode(' ', $currentClass);
        $classKey = array_search($class, $classes);
        if ($classKey === false) {
            return $element;
        }

        // Remove class and set new class attribute
        unset($classes[$classKey]);
        $newClass = implode(' ', $classes);

        // Update attribute
        $this->attr($element, 'class', empty($newClass) ? null : $newClass);

        // Return the HTML element
        return $element;
    }
1035725
public function setFormFieldCssClass($cssClass)
    {
        $cssClass = array_merge($this->defaultFormFieldCssClasses(), $this->parseCssClasses($cssClass));
        $this->formFieldCssClass = array_unique($cssClass);
        return $this;
    }