Generator
extends AbstractGenerator
in package
Uses
DocblockTrait
Generator code class
Tags
Table of Contents
Properties
- $close : bool
- Flag to close the code file with ?>
- $code : array<string|int, mixed>
- Code generator objects
- $docblock : DocblockGenerator|null
- Docblock generator object
- $env : string|null
- Environment setting, i.e. #!/usr/bin/php
- $filename : string|null
- Code filename
- $indent : int
- Code indent spaces
- $namespaces : array<string|int, mixed>
- Namespaces for the code generator objects
- $output : string|null
- Output string
Methods
- __construct() : mixed
- Constructor
- __toString() : string
- Print code
- addCodeObject() : Generator
- Add a code generator object
- addCodeObjects() : Generator
- Add code generator objects
- code() : array<string|int, mixed>
- Access the code generator objects (alias method)
- getCode() : array<string|int, mixed>
- Access the code generator object
- getDesc() : string|null
- Get the docblock description
- getDocblock() : DocblockGenerator|null
- Access the docblock generator object
- getEnv() : string|null
- Get the environment
- getFilename() : string|null
- Get filename
- getIndent() : int
- Get the indent
- getOutput() : string
- Get the output
- hasCloseTag() : bool
- Determine if the code close tag flag is set
- hasCode() : bool
- Has code generator objects
- hasDesc() : bool
- Has a docblock description
- hasDocblock() : bool
- Has docblock generator object
- hasEnv() : bool
- Determine if the environment is set
- hasFilename() : bool
- Has filename
- hasIndent() : bool
- Has indent
- hasOutput() : bool
- Has output
- isRendered() : bool
- Is rendered (alias to hasOutput())
- outputToHttp() : void
- Output to HTTP
- printIndent() : string
- Print the indent
- render() : string
- Render method
- setCloseTag() : Generator
- Set the code close tag flag
- setDesc() : static
- Set the docblock description
- setDocblock() : static
- Set the docblock generator object
- setEnv() : Generator
- Set the environment
- setFilename() : Generator
- Set the filename
- setIndent() : AbstractGenerator
- Set the indent
- writeToFile() : void
- Write to file
Properties
$close
Flag to close the code file with ?>
protected
bool
$close
= false
$code
Code generator objects
protected
array<string|int, mixed>
$code
= []
$docblock
Docblock generator object
protected
DocblockGenerator|null
$docblock
= null
$env
Environment setting, i.e. #!/usr/bin/php
protected
string|null
$env
= null
$filename
Code filename
protected
string|null
$filename
= null
$indent
Code indent spaces
protected
int
$indent
= 4
$namespaces
Namespaces for the code generator objects
protected
array<string|int, mixed>
$namespaces
= []
$output
Output string
protected
string|null
$output
= null
Methods
__construct()
Constructor
public
__construct([mixed $code = null ]) : mixed
Instantiate the code generator object
Parameters
- $code : mixed = null
Tags
__toString()
Print code
public
__toString() : string
Return values
stringaddCodeObject()
Add a code generator object
public
addCodeObject(GeneratorInterface $codeObject[, string|null $namespace = null ]) : Generator
Parameters
- $codeObject : GeneratorInterface
- $namespace : string|null = null
Return values
GeneratoraddCodeObjects()
Add code generator objects
public
addCodeObjects(array<string|int, mixed> $codeObjects) : Generator
Parameters
- $codeObjects : array<string|int, mixed>
Return values
Generatorcode()
Access the code generator objects (alias method)
public
code() : array<string|int, mixed>
Return values
array<string|int, mixed>getCode()
Access the code generator object
public
getCode() : array<string|int, mixed>
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|nullgetEnv()
Get the environment
public
getEnv() : string|null
Return values
string|nullgetFilename()
Get filename
public
getFilename() : string|null
Return values
string|nullgetIndent()
Get the indent
public
getIndent() : int
Return values
intgetOutput()
Get the output
public
getOutput() : string
Return values
stringhasCloseTag()
Determine if the code close tag flag is set
public
hasCloseTag() : bool
Return values
boolhasCode()
Has code generator objects
public
hasCode() : bool
Return values
boolhasDesc()
Has a docblock description
public
hasDesc() : bool
Return values
boolhasDocblock()
Has docblock generator object
public
hasDocblock() : bool
Return values
boolhasEnv()
Determine if the environment is set
public
hasEnv() : bool
Return values
boolhasFilename()
Has filename
public
hasFilename() : bool
Return values
boolhasIndent()
Has indent
public
hasIndent() : bool
Return values
boolhasOutput()
Has output
public
hasOutput() : bool
Return values
boolisRendered()
Is rendered (alias to hasOutput())
public
isRendered() : bool
Return values
booloutputToHttp()
Output to HTTP
public
outputToHttp([string|null $filename = null ][, bool $forceDownload = false ][, array<string|int, mixed> $headers = [] ]) : void
Parameters
- $filename : string|null = null
- $forceDownload : bool = false
- $headers : array<string|int, mixed> = []
printIndent()
Print the indent
public
printIndent() : string
Return values
stringrender()
Render method
public
render() : string
Return values
stringsetCloseTag()
Set the code close tag flag
public
setCloseTag([bool $close = false ]) : Generator
Parameters
- $close : bool = false
Return values
GeneratorsetDesc()
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
staticsetEnv()
Set the environment
public
setEnv([string|null $env = null ]) : Generator
Parameters
- $env : string|null = null
Return values
GeneratorsetFilename()
Set the filename
public
setFilename(string $filename) : Generator
Parameters
- $filename : string
Return values
GeneratorsetIndent()
Set the indent
public
setIndent(int $indent) : AbstractGenerator
Parameters
- $indent : int
Return values
AbstractGeneratorwriteToFile()
Write to file
public
writeToFile([string|null $filename = null ]) : void
Parameters
- $filename : string|null = null