Create getter setter
Declaring a member variable in the class, placing the cursor on the declared variable, selecting the Generate menu of the Code menu or pressing the shortcut key Alt + Insert, the Generate pop-up appears.
If you select the Getters and Setters.. item in the pop-up, the Choose Fields pop-up appears. Select all variables to add getter setters and click the OK button to automatically add a function to the editor.
The getter setter is added in camel notation, but if you change the setting, it can be changed to the underbar format.
To change to the underbar format, select File and Code Templates in Settings and PHP Getter in the Code tab.
In the edit window, change the function ${GET_OR_IS}${NAME} to function ${GET_OR_IS}_${FIELD_NAME}.
/**
* @return ${TYPE_HINT}
*/
public ${STATIC} function ${GET_OR_IS}${NAME}()#if(${RETURN_TYPE}): ${RETURN_TYPE}#else#end
{
#if (${STATIC} == "static")
return self::$${FIELD_NAME};
#else
return $this->${FIELD_NAME};
#end
}
/**
* @return ${TYPE_HINT}
*/
public ${STATIC} function ${GET_OR_IS}_${FIELD_NAME}()#if(${RETURN_TYPE}): ${RETURN_TYPE}#else#end
{
#if (${STATIC} == "static")
return self::$${FIELD_NAME};
#else
return $this->${FIELD_NAME};
#end
}
In the same way, select PHP Setter Method in the Code tab.
Change the function set${NAME} part to function set_${FIELD_NAME}.
/**
* @param ${TYPE_HINT} $${PARAM_NAME}
*/
public ${STATIC} function set${NAME}(#if (${SCALAR_TYPE_HINT})${SCALAR_TYPE_HINT} #else#end$${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 set_${FIELD_NAME}(#if (${SCALAR_TYPE_HINT})${SCALAR_TYPE_HINT} #else#end$${PARAM_NAME})
{
#if (${STATIC} == "static")
self::$${FIELD_NAME} = $${PARAM_NAME};
#else
$this->${FIELD_NAME} = $${PARAM_NAME};
#end
}
Click OK to save the settings.
https://stackoverflow.com/questions/6768793/get-the-full-url-in-php