PHP Class Iber\Generator\Utilities\SetGetGenerator

Show file Open project: ignasbernotas/laravel-model-generator Class Usage Examples

Protected Properties

Property Type Description
$attributes array Lists of attributes to convert
$getStub string Returns a template stub for get function
$setStub string Returns a template stub for set function

Public Methods

Method Description
__construct ( array $attributes, string $getStub, string $setStub ) [__construct description]
attributeNameToFunction ( string $prefixFunction, string $str, array $noStrip = [] ) : string Converts the given string to function. Support database names (underscores)
createGetFunctionFromAttributeName ( string $attributeName ) : string Bulds the get function for the attribute name
createSetFunctionFromAttributeName ( string $attributeName ) : string Bulds the set function for the attribute name
generateGetFunctions ( ) : string Returns the get functions in string
generateSetFunctions ( ) : string Returns the set functions in string

Protected Methods

Method Description
createAttributeFunction ( string $stubTemplate, string $function, string $attributeName ) : string Replaces the stub template with the data
createFunctionFromAttributeName ( string $prefixFunction, string $attributeName, string $stubTemplate ) : string Builds the funciton and creates the function from the stub template
generateWithFunction ( string $function ) : string Loops the attributes and build the string with given function name

Method Details

__construct() public method

[__construct description]
public __construct ( array $attributes, string $getStub, string $setStub )
$attributes array with attributes names
$getStub string set stub template
$setStub string get stub template

attributeNameToFunction() public method

Converts the given string to function. Support database names (underscores)
public attributeNameToFunction ( string $prefixFunction, string $str, array $noStrip = [] ) : string
$prefixFunction string desired function prefix (get/set)
$str string attribute name
$noStrip array
return string

createAttributeFunction() protected method

Replaces the stub template with the data
protected createAttributeFunction ( string $stubTemplate, string $function, string $attributeName ) : string
$stubTemplate string
$function string
$attributeName string
return string

createFunctionFromAttributeName() protected method

Builds the funciton and creates the function from the stub template
protected createFunctionFromAttributeName ( string $prefixFunction, string $attributeName, string $stubTemplate ) : string
$prefixFunction string
$attributeName string
$stubTemplate string
return string

createGetFunctionFromAttributeName() public method

Bulds the get function for the attribute name
public createGetFunctionFromAttributeName ( string $attributeName ) : string
$attributeName string
return string

createSetFunctionFromAttributeName() public method

Bulds the set function for the attribute name
public createSetFunctionFromAttributeName ( string $attributeName ) : string
$attributeName string
return string

generateGetFunctions() public method

Returns the get functions in string
public generateGetFunctions ( ) : string
return string

generateSetFunctions() public method

Returns the set functions in string
public generateSetFunctions ( ) : string
return string

generateWithFunction() protected method

Loops the attributes and build the string with given function name
protected generateWithFunction ( string $function ) : string
$function string
return string

Property Details

$attributes protected property

Lists of attributes to convert
protected array $attributes
return array

$getStub protected property

Returns a template stub for get function
protected string $getStub
return string

$setStub protected property

Returns a template stub for set function
protected string $setStub
return string