EnumCaseGenerator
extends AbstractGenerator
in package
uses
NameTrait, DocblockTrait, AttributesTrait
Enum case generator class
Tags
Table of Contents
Properties
- $attributes : array<string|int, mixed>
- Attributes. An indexed list, not keyed by name — attributes can legitimately repeat (Attribute::IS_REPEATABLE), so a name-keyed map would silently collapse repeats.
- $docblock : DocblockGenerator|null
- Docblock generator object
- $indent : int
- Code indent spaces
- $name : string|null
- Name
- $output : string|null
- Output string
- $value : int|string|null
- Case value (backed enums only)
Methods
- __construct() : mixed
- Constructor
- __toString() : string
- Print case
- addAttribute() : static
- Add an attribute
- addAttributes() : static
- Add attributes
- getAttributes() : array<string|int, mixed>
- Get all attributes
- getAttributesByName() : array<string|int, mixed>
- Get all attributes with the given name (supports repeated attributes)
- getDesc() : string|null
- Get the docblock description
- getDocblock() : DocblockGenerator|null
- Access the docblock generator object
- getIndent() : int
- Get the indent
- getName() : string|null
- Get the name
- getOutput() : string|null
- Get the output
- getValue() : int|string|null
- Get the case value
- hasAttribute() : bool
- Has an attribute with the given name
- hasAttributes() : bool
- Has attributes
- hasDesc() : bool
- Has a docblock description
- hasDocblock() : bool
- Has docblock generator object
- hasIndent() : bool
- Has indent
- hasName() : bool
- Get the name
- hasOutput() : bool
- Has output
- hasValue() : bool
- Has case value
- isRendered() : bool
- Is rendered (alias to hasOutput())
- printIndent() : string
- Print the indent
- removeAttribute() : static
- Remove an attribute (by instance identity — there is no unique name to remove by)
- render() : string
- Render case
- setDesc() : static
- Set the docblock description
- setDocblock() : static
- Set the docblock generator object
- setIndent() : AbstractGenerator
- Set the indent
- setName() : static
- Set the name
- setValue() : EnumCaseGenerator
- Set the case value
- formatAttributes() : string
- Format the attributes
Properties
$attributes
Attributes. An indexed list, not keyed by name — attributes can legitimately repeat (Attribute::IS_REPEATABLE), so a name-keyed map would silently collapse repeats.
protected
array<string|int, mixed>
$attributes
= []
$docblock
Docblock generator object
protected
DocblockGenerator|null
$docblock
= null
$indent
Code indent spaces
protected
int
$indent
= 4
$name
Name
protected
string|null
$name
= null
$output
Output string
protected
string|null
$output
= null
$value
Case value (backed enums only)
protected
int|string|null
$value
= null
Methods
__construct()
Constructor
public
__construct(string $name[, int|string|null $value = null ]) : mixed
Instantiate the enum case generator object
Parameters
- $name : string
- $value : int|string|null = null
__toString()
Print case
public
__toString() : string
Return values
stringaddAttribute()
Add an attribute
public
addAttribute(AttributeGenerator $attribute) : static
Parameters
- $attribute : AttributeGenerator
Return values
staticaddAttributes()
Add attributes
public
addAttributes(array<string|int, mixed> $attributes) : static
Parameters
- $attributes : array<string|int, mixed>
Return values
staticgetAttributes()
Get all attributes
public
getAttributes() : array<string|int, mixed>
Return values
array<string|int, mixed>getAttributesByName()
Get all attributes with the given name (supports repeated attributes)
public
getAttributesByName(string $name) : array<string|int, mixed>
Parameters
- $name : string
Return values
array<string|int, mixed>getDesc()
Get the docblock description
public
getDesc() : string|null
Return values
string|nullgetDocblock()
Access the docblock generator object
public
getDocblock() : DocblockGenerator|null
Return values
DocblockGenerator|nullgetIndent()
Get the indent
public
getIndent() : int
Return values
intgetName()
Get the name
public
getName() : string|null
Return values
string|nullgetOutput()
Get the output
public
getOutput() : string|null
Return values
string|nullgetValue()
Get the case value
public
getValue() : int|string|null
Return values
int|string|nullhasAttribute()
Has an attribute with the given name
public
hasAttribute(string $name) : bool
Parameters
- $name : string
Return values
boolhasAttributes()
Has attributes
public
hasAttributes() : bool
Return values
boolhasDesc()
Has a docblock description
public
hasDesc() : bool
Return values
boolhasDocblock()
Has docblock generator object
public
hasDocblock() : bool
Return values
boolhasIndent()
Has indent
public
hasIndent() : bool
Return values
boolhasName()
Get the name
public
hasName() : bool
Return values
boolhasOutput()
Has output
public
hasOutput() : bool
Return values
boolhasValue()
Has case value
public
hasValue() : bool
Return values
boolisRendered()
Is rendered (alias to hasOutput())
public
isRendered() : bool
Return values
boolprintIndent()
Print the indent
public
printIndent() : string
Return values
stringremoveAttribute()
Remove an attribute (by instance identity — there is no unique name to remove by)
public
removeAttribute(AttributeGenerator $attribute) : static
Parameters
- $attribute : AttributeGenerator
Return values
staticrender()
Render case
public
render() : string
Return values
stringsetDesc()
Set the docblock description
public
setDesc([string|null $desc = null ]) : static
Parameters
- $desc : string|null = null
Return values
staticsetDocblock()
Set the docblock generator object
public
setDocblock(DocblockGenerator $docblock) : static
Parameters
- $docblock : DocblockGenerator
Return values
staticsetIndent()
Set the indent
public
setIndent(int $indent) : AbstractGenerator
Parameters
- $indent : int
Return values
AbstractGeneratorsetName()
Set the name
public
setName(string $name) : static
Parameters
- $name : string
Return values
staticsetValue()
Set the case value
public
setValue([int|string|null $value = null ]) : EnumCaseGenerator
Parameters
- $value : int|string|null = null
Return values
EnumCaseGeneratorformatAttributes()
Format the attributes
protected
formatAttributes([bool $indented = true ]) : string
Parameters
- $indented : bool = true