PHP Trait gossi\codegen\model\parts\ParametersPart

For all models that can have parameters
Author: Thomas Gossmann
Datei anzeigen Open project: gossi/php-code-generator

Public Methods

Method Description
addParameter ( PhpParameter $parameter ) Adds a parameter
addSimpleDescParameter ( string $name, null | string $type = null, null | string $typeDescription = null, mixed $defaultValue = null ) A quick way to add a parameter with description which is created from the given parameters
addSimpleParameter ( string $name, null | string $type = null, mixed $defaultValue = null ) A quick way to add a parameter which is created from the given parameters
getParameter ( string | integer $nameOrIndex ) : PhpParameter Returns a parameter by index or name
getParameters ( ) : array Returns a collection of parameters
hasParameter ( string $name ) : boolean Checks whether a parameter exists
removeParameter ( integer | string | PhpParameter $param ) Remove a parameter at a given position
replaceParameter ( integer $position, PhpParameter $parameter ) Replaces a parameter at a given position
setParameters ( array $parameters ) Sets a collection of parameters

Protected Methods

Method Description
generateParamDocblock ( ) Generates docblock for params
getDocblock ( ) : Docblock Returns the docblock

Private Methods

Method Description
checkPosition ( $position )
initParameters ( )
removeParameterByName ( $name )
removeParameterByPosition ( $position )

Method Details

addParameter() public method

Adds a parameter
public addParameter ( PhpParameter $parameter )
$parameter gossi\codegen\model\PhpParameter

addSimpleDescParameter() public method

A quick way to add a parameter with description which is created from the given parameters
public addSimpleDescParameter ( string $name, null | string $type = null, null | string $typeDescription = null, mixed $defaultValue = null )
$name string
$type null | string
$typeDescription null | string
$defaultValue mixed omit the argument to define no default value

addSimpleParameter() public method

A quick way to add a parameter which is created from the given parameters
public addSimpleParameter ( string $name, null | string $type = null, mixed $defaultValue = null )
$name string
$type null | string
$defaultValue mixed omit the argument to define no default value

generateParamDocblock() protected method

Generates docblock for params
protected generateParamDocblock ( )

getDocblock() abstract protected method

Returns the docblock
abstract protected getDocblock ( ) : Docblock
return Docblock

getParameter() public method

Returns a parameter by index or name
public getParameter ( string | integer $nameOrIndex ) : PhpParameter
$nameOrIndex string | integer
return gossi\codegen\model\PhpParameter

getParameters() public method

Returns a collection of parameters
public getParameters ( ) : array
return array

hasParameter() public method

Checks whether a parameter exists
public hasParameter ( string $name ) : boolean
$name string parameter name
return boolean `true` if a parameter exists and `false` if not

removeParameter() public method

Remove a parameter at a given position
public removeParameter ( integer | string | PhpParameter $param )
$param integer | string | gossi\codegen\model\PhpParameter

replaceParameter() public method

Replaces a parameter at a given position
public replaceParameter ( integer $position, PhpParameter $parameter )
$position integer
$parameter gossi\codegen\model\PhpParameter

setParameters() public method

Note: clears all parameters before setting the new ones
public setParameters ( array $parameters )
$parameters array