Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Sublime custom template for PHP Getters and Setters package
# Save the file to "{Sublime Packages}/PHP Getters and Setters/user_templates.py"
# Then add following "user config" in Sublime Text:
#
# {
# "registerTemplates" : [ "customTemplate" ],
# "template" : "customTemplate"
# }
#
# Restart Sublime Text
#
# @link https://github.com/francodacosta/sublime-php-getters-setters
class customTemplate(object):
name = "customTemplate"
style = 'camelCase' # can also be snakeCase
getter = """
/**
* Gets the %(description)s
* @return %(type)s
*/
public function get%(normalizedName)s()
{
return $this->%(name)s;
}
"""
setter = """
/**
* Sets the %(description)s
*
* @param %(type)s $%(name)s
* @return self
*/
public function set%(normalizedName)s(%(typeHint)s $%(name)s)
{
$this->%(name)s = $%(name)s;
}
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment