class Variable extends GenericQualifier

Defines methods for using variables.

Learn more: User defined variables

Methods

set(string $name, mixed $value)

Defines a new user variable with the given value.

setAssetReference(string $name, mixed $publicId)

Defines a new user variable with the given asset public id.

setFromContext(string $name, mixed $contextKey)

Defines a new user variable with the given context key.

setFromMetadata(string $name, mixed $metadataKey)

Defines a new user variable with the given structured metadata key.

asFloat(bool $asFloat = true)

Indicates Cloudinary to treat the value as float.

asInteger(bool $asInteger = true)

Indicates Cloudinary to treat the value as integer.

setKey(string $name)

Sets the variable name as the qualifier key.

setQualifierValue(...$value)

Sets ((re)initializes) the qualifier value.

getVariableName()

Returns the variable name.

isVariable(string $candidate)

Determines whether the candidate is a valid variable name.

jsonSerialize()

Serializes to json.

Details

static Variable set(string $name, mixed $value)

Defines a new user variable with the given value.

Parameters

Name Type Description
$name string The name of the variable.
$value mixed The value of the variable.

Return Value

Variable

static Variable setAssetReference(string $name, mixed $publicId)

Defines a new user variable with the given asset public id.

Parameters

Name Type Description
$name string The name of the variable.
$publicId mixed The referenced asset public id.

Return Value

Variable

static Variable setFromContext(string $name, mixed $contextKey)

Defines a new user variable with the given context key.

Parameters

Name Type Description
$name string The name of the variable.
$contextKey mixed The context key.

Return Value

Variable

static Variable setFromMetadata(string $name, mixed $metadataKey)

Defines a new user variable with the given structured metadata key.

Parameters

Name Type Description
$name string The name of the variable.
$metadataKey mixed The metadata key.

Return Value

Variable

$this asFloat(bool $asFloat = true)

Indicates Cloudinary to treat the value as float.

Parameters

Name Type Description
$asFloat bool Whether to treat as float.

Return Value

$this

$this asInteger(bool $asInteger = true)

Indicates Cloudinary to treat the value as integer.

Parameters

Name Type Description
$asInteger bool Whether to treat as integer.

Return Value

$this

Variable setKey(string $name)

Sets the variable name as the qualifier key.

Parameters

Name Type Description
$name string The name of the variable.

Return Value

Variable

Variable setQualifierValue(...$value)

Sets ((re)initializes) the qualifier value.

Parameters

Name Type Description
...$value

Return Value

Variable

string getVariableName()

Returns the variable name.

Return Value

string

static bool isVariable(string $candidate)

Determines whether the candidate is a valid variable name.

Parameters

Name Type Description
$candidate string Variable name candidate.

Return Value

bool

mixed jsonSerialize()

Serializes to json.

Return Value

mixed

Constants

VALUE_CLASS

AS_FLOAT

AS_INTEGER