master

laravel/framework

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

Expression.php

TLDR

This file contains the class Expression, which is used to represent raw query expressions in the Illuminate\Database\Query namespace.

Classes

Expression

The Expression class is used to represent raw query expressions. It implements the ExpressionContract interface. It has the following properties and methods:

Properties

  • $value: The value of the expression. It can be a string, integer, or float.

Methods

__construct($value)

This method is the constructor of the Expression class. It accepts a parameter $value of type string, integer, or float. It initializes the $value property with the provided value.

getValue(Grammar $grammar)

This method is used to get the value of the expression. It accepts a parameter $grammar of type Grammar. It returns the value of the expression, which can be a string, integer, or float.

<?php

namespace Illuminate\Database\Query;

use Illuminate\Contracts\Database\Query\Expression as ExpressionContract;
use Illuminate\Database\Grammar;

class Expression implements ExpressionContract
{
    /**
     * The value of the expression.
     *
     * @var string|int|float
     */
    protected $value;

    /**
     * Create a new raw query expression.
     *
     * @param  string|int|float  $value
     * @return void
     */
    public function __construct($value)
    {
        $this->value = $value;
    }

    /**
     * Get the value of the expression.
     *
     * @param  \Illuminate\Database\Grammar  $grammar
     * @return string|int|float
     */
    public function getValue(Grammar $grammar)
    {
        return $this->value;
    }
}