Oihana PHP Arango

nullish.php

Table of Contents

Functions

nullish()  : string
Generates a shorthand nullish ternary expression.

Functions

nullish()

Generates a shorthand nullish ternary expression.

nullish(string $condition[, mixed|null $defaultValue = null ]) : string

This is a variant of the ternary operator that only requires a condition and a default value. The expression evaluates the $condition; if it is "truthy", the value is returned, otherwise the $defaultValue is returned.

Example:

nullish('u.value', 'default') // Produces: "u.value ? : default"

Useful for building concise AQL expressions where you want to provide a fallback if a field is null, missing, or evaluates to false.

Parameters
$condition : string

Boolean expression to evaluate (e.g. a field reference)

$defaultValue : mixed|null = null

Value to return if the condition is false

Return values
string

A string representing the nullish ternary expression

On this page

Search results