src/View/Helper/ClassTrait.php
public function addClass(array $options = [], $class = null, $key = 'class') {
        if (!is_array($class)) {
            $class = explode(' ', trim($class));
        }
        $optClass = [];
        if (isset($options[$key])) {
            $optClass = $options[$key];
            if (!is_array($optClass)) {
                $optClass = explode(' ', trim($optClass));
            }
        }
        $class = array_merge($optClass, $class);
        $class = array_map('trim', $class);
        $class = array_unique($class);
        $class = array_filter($class);
        $options[$key] = implode(' ', $class);
        return $options;
    }
public function addClass(array $options = [], $class = null, $key = 'class') {
        if (!is_array($class)) {
            $class = explode(' ', trim($class));
        }
        $optClass = [];
        if (isset($options[$key])) {
            $optClass = $options[$key];
            if (!is_array($optClass)) {
                $optClass = explode(' ', trim($optClass));
            }
        }
        $class = array_merge($optClass, $class);
        $class = array_map('trim', $class);
        $class = array_unique($class);
        $class = array_filter($class);
        $options[$key] = implode(' ', $class);
        return $options;
    }
public function addClass ( array $ options = [ ] , $ class = null , $ key = 'class' ) { if ( ! is_array ( $ class ) ) { $ class = explode ( ' ' , trim ( $ class ) ) ; } $ optClass = [ ] ; if ( isset ( $ options [ $ key ] ) ) { $ optClass = $ options [ $ key ] ; if ( ! is_array ( $ optClass ) ) { $ optClass = explode ( ' ' , trim ( $ optClass ) ) ; } } $ class = array_merge ( $ optClass , $ class ) ; $ class = array_map ( 'trim' , $ class ) ; $ class = array_unique ( $ class ) ; $ class = array_filter ( $ class ) ; $ options [ $ key ] = implode ( ' ' , $ class ) ; return $ options ; }
Adds the given class to the element options.

@param array        $options Array of options/attributes to add a class to.
@param string|array $class   The class names to be added.
@param string       $key     The key to use for class (default to `'class'`).

@return array Array of options with `$key` set or updated.
Adds the given class to the element options .