This documentation describes unreleased changes on the main branch.

EnumField

Class. It extends Field.

use Saij\WpAppFramework\Query\Field\EnumField;

A backed enum field of a meta class or a column of a table, stored as the value of its case.

Constructor

new EnumField(string $class, string $field, string $enum)
ParameterTypeDefaultDescription
classclass-stringrequiredThe class the field belongs to: a meta class (#[PostMeta]) or row class (#[Table]).
fieldstringrequiredThe name of the constructor parameter.
enumclass-string<E>requiredThe enum of the field.

Methods

equals()

equals(BackedEnum $case): Condition

Matches the case $case. Throws an InvalidArgumentException if $case is a case of another enum.

ParameterTypeDefaultDescription
caseErequiredA case of the enum of the field.

Returns Condition

getClass()

getClass(): string

The class the field belongs to.

Returns class-string

getField()

getField(): string

The name of the field: the name of the constructor parameter.

Returns string

in()

in(BackedEnum ...$cases): Condition

Matches one of the cases $cases. Throws an InvalidArgumentException if no case or a case of another enum is given.

ParameterTypeDefaultDescription
...casesECases of the enum of the field.

Returns Condition

notEquals()

notEquals(BackedEnum $case): Condition

Matches every case but $case. On a nullable column, rows whose column is null match as well. Throws an InvalidArgumentException if $case is a case of another enum.

ParameterTypeDefaultDescription
caseErequiredA case of the enum of the field.

Returns Condition

notIn()

notIn(BackedEnum ...$cases): Condition

Matches none of the cases $cases. On a nullable column, rows whose column is null match as well. Throws an InvalidArgumentException if no case or a case of another enum is given.

ParameterTypeDefaultDescription
...casesECases of the enum of the field.

Returns Condition