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

4 comments

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.

0

Hello!

This is wonderful!!

Thank you

0

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

0

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.

0

Please sign in to leave a comment.