master

laravel/framework

Last updated at: 29/12/2023 09:25

CompilesClasses.php

TLDR

The CompilesClasses.php file contains a trait called CompilesClasses which compiles a conditional class statement into valid PHP code.

Methods

None

Classes

None

<?php

namespace Illuminate\View\Compilers\Concerns;

trait CompilesClasses
{
    /**
     * Compile the conditional class statement into valid PHP.
     *
     * @param  string  $expression
     * @return string
     */
    protected function compileClass($expression)
    {
        $expression = is_null($expression) ? '([])' : $expression;

        return "class=\"<?php echo \Illuminate\Support\Arr::toCssClasses{$expression}; ?>\"";
    }
}