interface ConstantsInterface

Interface to all php structs that can have constants

Implementation is realized in the ConstantsPart

Methods

$this
setConstants(array $constants)

Sets a collection of constants

$this
setConstant(string|PhpConstant $nameOrConstant, string $value = null)

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

getConstants()

Returns constants

string[]
getConstantNames()

Returns all constant names

$this
clearConstants()

Clears all constants

Details

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

Sets a collection of constants

Parameters

array $constants

Return Value

$this

at line line 28
$this setConstant(string|PhpConstant $nameOrConstant, string $value = null)

Adds a constant

Parameters

string|PhpConstant $nameOrConstant constant or name
string $value

Return Value

$this

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

Removes a constant

Parameters

string|PhpConstant $nameOrConstant $nameOrConstant constant or name

Return Value

$this

Exceptions

InvalidArgumentException If the constant cannot be found

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

Checks whether a constant exists

Parameters

string|PhpConstant $nameOrConstant

Return Value

bool

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

Returns a constant

Parameters

string|PhpConstant $nameOrConstant constant or name

Return Value

PhpConstant

Exceptions

InvalidArgumentException If the constant cannot be found

at line line 61
PhpConstant[] getConstants()

Returns constants

Return Value

PhpConstant[]

at line line 68
string[] getConstantNames()

Returns all constant names

Return Value

string[]

at line line 75
$this clearConstants()

Clears all constants

Return Value

$this