Code -> Generate -> Getters and Setters
Hello!
Is possible with 'code' -> 'Generate Code' -> 'Getters and Setters' to generate additional methods.
For example:
{class myTest
private $ _lastname = null;
public function setLastname ($ lastName) {
...
}
public function getLastname() {
}
public function isLastname() { // new
}
public function isValidLastname() { // new
}
public function validateLastname() { // new
}
public function filterLastname () { // new
}
}
Sincerely yours
Stephan
Please sign in to leave a comment.
Hi there,
The templates used for this are located at "Settings | File and Code Templates | Code" -- you can alter them as you wish.
You can add additional methods in such template and see if it will work. If not -- then you may create some custom Live Template and use it to help generating such methods.
Hello!
This is wonderful!!
Thank you
Hello!
Is there a way to create more in-line templates.
I modified the inline template for 'set'.
It is only taken over the last change.
For example, there is only 'validate' used.
------------------------------------
/**
* @param ${TYPE_HINT} $${PARAM_NAME}
*/
public ${STATIC} function set${NAME}($${PARAM_NAME})
{
#if (${STATIC} == "static")
self::$${FIELD_NAME} = $${PARAM_NAME};
#else
$this->${FIELD_NAME} = $${PARAM_NAME};
#end
}
/**
* @param ${TYPE_HINT} $${PARAM_NAME}
*/
public ${STATIC} function validate${NAME}($${PARAM_NAME})
{
#if (${STATIC} == "static")
return $${PARAM_NAME};
#else
return = $${PARAM_NAME};
#end
}
---------------------------------
Sincerely yours
Stephan
As I suspected it does not work this way right now: http://youtrack.jetbrains.com/issue/WI-12552
Use Live Template to help you creating other methods.