Last active
October 12, 2015 11:30
-
-
Save ephrin/25ef81e8933b34d0355b to your computer and use it in GitHub Desktop.
PHPStorm: Editor -> File and Code Templates: Code -> PHP Setter Method
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param ${TYPE_HINT} $${PARAM_NAME} | |
* @return static | |
*/ | |
#set($th = $TYPE_HINT) | |
#set($ln = "|") | |
#set($be = "[]") | |
#set($aw = "array") | |
#set($c = ["int", "integer", "mixed", "str", "string", "bool", "boolean", "float", "double"]) | |
#set($o = '') | |
#if ($c.contains($th)) | |
#set($hint = "") | |
#elseif($th.contains($be) && !$th.contains($ln)) | |
#set($hint = "array ") | |
#elseif($th.contains($be) && $th.contains($ln) && $th.contains($aw)) | |
#set($hint = "array ") | |
#elseif($th.contains($be) && $th.contains($ln) && !$th.contains($aw)) | |
#set($hint = "") | |
#elseif(!$th.contains($be) && $th.contains($ln) && !$th.contains($aw)) | |
#set($hint = "") | |
#else | |
#set($hint = "$TYPE_HINT ") | |
#end | |
public ${STATIC} function set${NAME}(${hint}$${PARAM_NAME}) | |
{ | |
#if (${STATIC} == "static") | |
self::$${FIELD_NAME} = $${PARAM_NAME}; | |
#else | |
$this->${FIELD_NAME} = $${PARAM_NAME}; | |
#end | |
return $this; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment