master

laravel/framework

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

CompilesStyles.php

TLDR

This file is a trait called CompilesStyles in the Illuminate\View\Compilers\Concerns namespace. It provides a method called compileStyle that compiles a conditional style statement into valid PHP.

Methods

compileStyle

Compile the conditional style statement into valid PHP.

Classes

This file does not contain any classes.

<?php

namespace Illuminate\View\Compilers\Concerns;

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

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