yii\helpers\BaseHtml::addCssClass PHP Method

addCssClass() public static method

If the CSS class is already in the options, it will not be added again. If class specification at given options is an array, and some class placed there with the named (string) key, overriding of such key will have no effect. For example: php $options = ['class' => ['persistent' => 'initial']]; Html::addCssClass($options, ['persistent' => 'override']); var_dump($options['class']); // outputs: array('persistent' => 'initial');
public static addCssClass ( array &$options, string | array $class )
$options array the options to be modified.
$class string | array the CSS class(es) to be added
    public static function addCssClass(&$options, $class)
    {
        if (isset($options['class'])) {
            if (is_array($options['class'])) {
                $options['class'] = self::mergeCssClasses($options['class'], (array) $class);
            } else {
                $classes = preg_split('/\\s+/', $options['class'], -1, PREG_SPLIT_NO_EMPTY);
                $options['class'] = implode(' ', self::mergeCssClasses($classes, (array) $class));
            }
        } else {
            $options['class'] = $class;
        }
    }