trait ConstantsPart

Constants part

For all models that can contain constants

Methods

$this
setConstants(array $constants)

Sets a collection of constants

$this
setConstant($nameOrConstant, $value = null, $isExpression = false)

Adds a constant

$this
removeConstant(string|PhpConstant $nameOrConstant)

Removes a constant

bool
hasConstant(string|PhpConstant $nameOrConstant)

Checks whether a constant exists

getConstant(string|PhpConstant $nameOrConstant)

Returns a constant.

Map
getConstants()

Returns all constants

Set
getConstantNames()

Returns all constant names

$this
clearConstants()

Clears all constants

Details

at line line 30
$this setConstants(array $constants)

Sets a collection of constants

Parameters

array $constants

Return Value

$this

at line line 56
$this setConstant($nameOrConstant, $value = null, $isExpression = false)

Adds a constant

Parameters

$nameOrConstant
$value
$isExpression

Return Value

$this

at line line 77
$this removeConstant(string|PhpConstant $nameOrConstant)

Removes a constant

Parameters

string|PhpConstant $nameOrConstant constant name

Return Value

$this

Exceptions

InvalidArgumentException If the constant cannot be found

at line line 97
bool hasConstant(string|PhpConstant $nameOrConstant)

Checks whether a constant exists

Parameters

string|PhpConstant $nameOrConstant

Return Value

bool

at line line 112
PhpConstant getConstant(string|PhpConstant $nameOrConstant)

Returns a constant.

Parameters

string|PhpConstant $nameOrConstant

Return Value

PhpConstant

Exceptions

InvalidArgumentException If the constant cannot be found

at line line 129
Map getConstants()

Returns all constants

Return Value

Map

at line line 138
Set getConstantNames()

Returns all constant names

Return Value

Set

at line line 147
$this clearConstants()

Clears all constants

Return Value

$this