final class TemplateGenerator

Template code generator.

Methods

string
generate(TemplateNode $node, string $className, string|null $comment = null, bool $strictMode = false)

Compiles nodes to PHP file

void
addMethod(string $name, string $body, string $arguments = '', string $returns = 'void', string|null $comment = null)

Adds custom method to template.

array
getMethods()

Returns custom methods.

void
addProperty(string $name, mixed $value)

Adds custom property to template.

array
getProperties()

Returns custom properites.

void
addConstant(string $name, mixed $value)

Adds custom constant to template.

Details

at line 36
string generate(TemplateNode $node, string $className, string|null $comment = null, bool $strictMode = false)

Compiles nodes to PHP file

Parameters

TemplateNode $node
string $className
string|null $comment
bool $strictMode

Return Value

string

at line 153
void addMethod(string $name, string $body, string $arguments = '', string $returns = 'void', string|null $comment = null)

internal  
 

Adds custom method to template.

Parameters

string $name
string $body
string $arguments
string $returns
string|null $comment

Return Value

void

at line 170
array getMethods()

internal  
 

Returns custom methods.

Return Value

array

at line 180
void addProperty(string $name, mixed $value)

internal  
 

Adds custom property to template.

Parameters

string $name
mixed $value

Return Value

void

at line 191
array getProperties()

internal  
 

Returns custom properites.

Return Value

array

at line 201
void addConstant(string $name, mixed $value)

internal  
 

Adds custom constant to template.

Parameters

string $name
mixed $value

Return Value

void

Traits

Better OOP experience.