PHP Class Pop\Code\Generator\FunctionGenerator

Author: Nick Sagona, III ([email protected])
Mostra file Open project: nicksagona/PopPHP Class Usage Examples

Protected Properties

Property Type Description
$arguments array Function arguments
$body string Function body
$closure boolean Function interface flag
$docblock DocblockGenerator Docblock generator object
$indent string Function indent
$name string Function name
$output string Function output

Public Methods

Method Description
__construct ( string $name, mixed $func = null ) : FunctionGenerator Constructor
__toString ( ) : string Print method
addArgument ( string $name, mixed $value = null, string $type = null ) : FunctionGenerator Add a function argument
addArguments ( array $args ) : FunctionGenerator Add function arguments
addParameter ( string $name, mixed $value = null, string $type = null ) : FunctionGenerator Add a function argument (synonym method for convenience)
addParameters ( array $args ) : FunctionGenerator Add function arguments (synonym method for convenience)
appendToBody ( string $body, boolean $newline = true ) : FunctionGenerator Append to the function body
factory ( string $name, mixed $func = null ) : FunctionGenerator Static method to instantiate the function generator object and return itself to facilitate chaining methods together.
getArgument ( string $name ) : array Get a function argument
getArgumentNames ( ) : array Get the function arguments
getArguments ( ) : array Get the function arguments
getBody ( ) : string Get the function body
getDesc ( ) : string Get the function description
getDocblock ( ) : DocblockGenerator Access the docblock generator object
getIndent ( ) : string Get the function indent
getName ( ) : string Get the function name
getParameter ( string $name ) : array Get a function argument (synonym method for convenience)
getParameterNames ( ) : array Get the function arguments (synonym method for convenience)
getParameters ( ) : array Get the function arguments (synonym method for convenience)
isClosure ( ) : boolean Get the function closure flag
render ( boolean $ret = false ) : mixed Render method
setBody ( string $body, boolean $newline = true ) : FunctionGenerator Set the function body
setClosure ( boolean $closure = false ) : FunctionGenerator Set the function closure flag
setDesc ( string $desc = null ) : FunctionGenerator Set the function description
setDocblock ( DocblockGenerator $docblock ) : ClassGenerator Set the docblock generator object
setIndent ( string $indent = null ) : FunctionGenerator Set the function indent
setName ( string $name ) : FunctionGenerator Set the function name

Protected Methods

Method Description
formatArguments ( ) : string Method to format the arguments
parseFunction ( mixed $func ) : void Method to format the arguments

Method Details

__construct() public method

Instantiate the function generator object
public __construct ( string $name, mixed $func = null ) : FunctionGenerator
$name string
$func mixed
return FunctionGenerator

__toString() public method

Print method
public __toString ( ) : string
return string

addArgument() public method

Add a function argument
public addArgument ( string $name, mixed $value = null, string $type = null ) : FunctionGenerator
$name string
$value mixed
$type string
return FunctionGenerator

addArguments() public method

Add function arguments
public addArguments ( array $args ) : FunctionGenerator
$args array
return FunctionGenerator

addParameter() public method

Add a function argument (synonym method for convenience)
public addParameter ( string $name, mixed $value = null, string $type = null ) : FunctionGenerator
$name string
$value mixed
$type string
return FunctionGenerator

addParameters() public method

Add function arguments (synonym method for convenience)
public addParameters ( array $args ) : FunctionGenerator
$args array
return FunctionGenerator

appendToBody() public method

Append to the function body
public appendToBody ( string $body, boolean $newline = true ) : FunctionGenerator
$body string
$newline boolean
return FunctionGenerator

factory() public static method

Static method to instantiate the function generator object and return itself to facilitate chaining methods together.
public static factory ( string $name, mixed $func = null ) : FunctionGenerator
$name string
$func mixed
return FunctionGenerator

formatArguments() protected method

Method to format the arguments
protected formatArguments ( ) : string
return string

getArgument() public method

Get a function argument
public getArgument ( string $name ) : array
$name string
return array

getArgumentNames() public method

Get the function arguments
public getArgumentNames ( ) : array
return array

getArguments() public method

Get the function arguments
public getArguments ( ) : array
return array

getBody() public method

Get the function body
public getBody ( ) : string
return string

getDesc() public method

Get the function description
public getDesc ( ) : string
return string

getDocblock() public method

Access the docblock generator object
public getDocblock ( ) : DocblockGenerator
return DocblockGenerator

getIndent() public method

Get the function indent
public getIndent ( ) : string
return string

getName() public method

Get the function name
public getName ( ) : string
return string

getParameter() public method

Get a function argument (synonym method for convenience)
public getParameter ( string $name ) : array
$name string
return array

getParameterNames() public method

Get the function arguments (synonym method for convenience)
public getParameterNames ( ) : array
return array

getParameters() public method

Get the function arguments (synonym method for convenience)
public getParameters ( ) : array
return array

isClosure() public method

Get the function closure flag
public isClosure ( ) : boolean
return boolean

parseFunction() protected method

Method to format the arguments
protected parseFunction ( mixed $func ) : void
$func mixed
return void

render() public method

Render method
public render ( boolean $ret = false ) : mixed
$ret boolean
return mixed

setBody() public method

Set the function body
public setBody ( string $body, boolean $newline = true ) : FunctionGenerator
$body string
$newline boolean
return FunctionGenerator

setClosure() public method

Set the function closure flag
public setClosure ( boolean $closure = false ) : FunctionGenerator
$closure boolean
return FunctionGenerator

setDesc() public method

Set the function description
public setDesc ( string $desc = null ) : FunctionGenerator
$desc string
return FunctionGenerator

setDocblock() public method

Set the docblock generator object
public setDocblock ( DocblockGenerator $docblock ) : ClassGenerator
$docblock DocblockGenerator
return ClassGenerator

setIndent() public method

Set the function indent
public setIndent ( string $indent = null ) : FunctionGenerator
$indent string
return FunctionGenerator

setName() public method

Set the function name
public setName ( string $name ) : FunctionGenerator
$name string
return FunctionGenerator

Property Details

$arguments protected_oe property

Function arguments
protected array $arguments
return array

$body protected_oe property

Function body
protected string $body
return string

$closure protected_oe property

Function interface flag
protected bool $closure
return boolean

$docblock protected_oe property

Docblock generator object
protected DocblockGenerator,Pop\Code\Generator $docblock
return DocblockGenerator

$indent protected_oe property

Function indent
protected string $indent
return string

$name protected_oe property

Function name
protected string $name
return string

$output protected_oe property

Function output
protected string $output
return string