Skip to content
docsv0.24.0

EnumGenerator

Materialises a backed string enum as a CONSEQUENCE of an entity field, never as a command. The golden rule (greenhouse decisions/0180 + Rod's «agent declares semantics, the house chooses mechanics»): the agent declares the enum's cases — they are domain values, its to decide — inside the entity's `enum:Class(a,b,c)` field. The house makes the REPRESENTATION. There is deliberately no `make:enum` command: an enum is not a unit the agent thinks in, it is what an entity's field implies. This is a pure helper for {@see EntityGenerator}, not a `GeneratorInterface` in the make registry.

EnumGenerator::plannedFile()

public static function plannedFile(string $root, string $plugin, string $class, array $cases): Milpa\DevTools\Make\PlannedFile

Plans the enum file for a plugin — the seam {@see EntityGenerator} calls so an entity's `enum:Class(cases)` field is materialised, not left a dangling reference.

Parameters

Parameters of plannedFile()
NameTypeDescription
$rootstring
$pluginstring
$classstring
$caseslist<string>

EnumGenerator::render()

public static function render(string $namespace, string $class, array $cases): string

A backed string enum: the case NAME is a valid identifier derived from the declared case; the backing VALUE is the declared case string verbatim, so persistence (`Enum::from($row[...])`) round-trips the stored string. `alta` → `case alta = 'alta';`.

Parameters

Parameters of render()
NameTypeDescription
$namespacestring
$classstring
$caseslist<string>