src/Route/Middleware/WordPressBodyClass.php
protected function dispatchBodyClass(Route $route)
    {
        return function ($classes) use ($route) {
            if ($route->hasCondition()) {
                return $classes;
            }

            $tokens = array_filter(array_map(function ($token) use ($route) {
                switch ($type = $token[0]) {
                    case 'variable':
                        if (isset($token[3]) && $route->hasParameter($paramKey = $token[3])) {
                            $param = $route->parameter($paramKey);

                            return is_string($param) ? sprintf('%s-%s', $paramKey, sanitize_title($param)) : false;
                        }

                        return false;
                        break;
                    case 'text':
                        return sanitize_title($token[1]);
                        break;
                    default:
                        return false;
                }
            }, array_reverse($route->getCompiled()->getTokens())));

            if (! empty($tokens)) {
                return array_filter(array_merge($tokens, $classes), function ($class) {
                    return 'error404' !== $class;
                });
            }

            return $classes;
        };
    }
protected function dispatchBodyClass(Route $route)
    {
        return function ($classes) use ($route) {
            if ($route->hasCondition()) {
                return $classes;
            }

            $tokens = array_filter(array_map(function ($token) use ($route) {
                switch ($type = $token[0]) {
                    case 'variable':
                        if (isset($token[3]) && $route->hasParameter($paramKey = $token[3])) {
                            $param = $route->parameter($paramKey);

                            return is_string($param) ? sprintf('%s-%s', $paramKey, sanitize_title($param)) : false;
                        }

                        return false;
                        break;
                    case 'text':
                        return sanitize_title($token[1]);
                        break;
                    default:
                        return false;
                }
            }, array_reverse($route->getCompiled()->getTokens())));

            if (! empty($tokens)) {
                return array_filter(array_merge($tokens, $classes), function ($class) {
                    return 'error404' !== $class;
                });
            }

            return $classes;
        };
    }
protected function dispatchBodyClass ( Route $ route ) { return function ( $ classes ) use ( $ route ) { if ( $ route -> hasCondition ( ) ) { return $ classes ; } $ tokens = array_filter ( array_map ( function ( $ token ) use ( $ route ) { switch ( $ type = $ token [ 0 ] ) { case 'variable' : if ( isset ( $ token [ 3 ] ) && $ route -> hasParameter ( $ paramKey = $ token [ 3 ] ) ) { $ param = $ route -> parameter ( $ paramKey ) ; return is_string ( $ param ) ? sprintf ( '%s-%s' , $ paramKey , sanitize_title ( $ param ) ) : false ; } return false ; break ; case 'text' : return sanitize_title ( $ token [ 1 ] ) ; break ; default : return false ; } } , array_reverse ( $ route -> getCompiled ( ) -> getTokens ( ) ) ) ) ; if ( ! empty ( $ tokens ) ) { return array_filter ( array_merge ( $ tokens , $ classes ) , function ( $ class ) { return 'error404' !== $ class ; } ) ; } return $ classes ; } ; }
Return the callback managing route body CSS classes.

@param Route $route

@return \Closure
Return the callback managing route body CSS classes .