public static function mergeClasses($a, $b)
    {
        $str = 0;
        if (!is_array($a)) {
            $str++;
            $a = explode(' ', $a);
        }
        if (!is_array($b)) {
            $str++;
            $b = explode(' ', $b);
        }

        $b = array_filter($b, function ($item) use ($a) {
            return !in_array($item, $a);
        });

        $r = array_merge($a, $b);

        sort($r);

        if ($str === 2) {
            $r = implode(' ', $r);
        }

        return $r;
    }
public static function mergeClasses($a, $b)
    {
        $str = 0;
        if (!is_array($a)) {
            $str++;
            $a = explode(' ', $a);
        }
        if (!is_array($b)) {
            $str++;
            $b = explode(' ', $b);
        }

        $b = array_filter($b, function ($item) use ($a) {
            return !in_array($item, $a);
        });

        $r = array_merge($a, $b);

        sort($r);

        if ($str === 2) {
            $r = implode(' ', $r);
        }

        return $r;
    }
public static function mergeClasses ( $ a , $ b ) { $ str = 0 ; if ( ! is_array ( $ a ) ) { $ str ++ ; $ a = explode ( ' ' , $ a ) ; } if ( ! is_array ( $ b ) ) { $ str ++ ; $ b = explode ( ' ' , $ b ) ; } $ b = array_filter ( $ b , function ( $ item ) use ( $ a ) { return ! in_array ( $ item , $ a ) ; } ) ; $ r = array_merge ( $ a , $ b ) ; sort ( $ r ) ; if ( $ str === 2 ) { $ r = implode ( ' ' , $ r ) ; } return $ r ; }
Merge two strings or arrays of classes

@param  string|array $a
@param  string|array $b
@return string|array
Merge two strings or arrays of classes