Skip to content

Instantly share code, notes, and snippets.

@cristianciofu
Created December 11, 2013 09:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cristianciofu/7907223 to your computer and use it in GitHub Desktop.
Save cristianciofu/7907223 to your computer and use it in GitHub Desktop.
Sublime Text : getters & setters snippet
<!--
Generate getters and setters for your php sources
usage : gs <tab>
(c) http://akrabat.com/software/improved-sublime-text-2-php-getter-and-setter-generation/
-->
<snippet>
<content><![CDATA[/**
* Getter for ${1:$SELECTION}
*
* @return mixed
*/
public function get${1/(?:^|_)(\w)/\U$1$2/g$1}()
{
return \$this->$1;
}
/**
* Setter for $1
*
* @param mixed \$${1/_(\w)/\U$1/g$1} Value to set
*
* @return self
*/
public function set${1/(?:^|_)(\w)/\U$1$2/g$1}(\$${1/_(\w)/\U$1/g$1})
{
\$this->$1 = \$${1/_(\w)/\U$1/g$1};
return \$this;
}
]]></content>
<!-- Optional: Tab trigger to activate the snippet -->
<tabTrigger>gs</tabTrigger>
<!-- Optional: Scope the tab trigger will be active in -->
<scope>source.php</scope>
<!-- Optional: Description to show in the menu -->
<description>Create getter and setter methods</description>
</snippet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment