<snippet>
<content><![CDATA[
private \$${1:memberName};
public function get${1/(?:^|_)(.)/\u$1/g}()
{
return \$this->$1;
}
public function set${1/(?:^|_)(.)/\u$1/g}(\$${2:value})
{
\$this->$1 = \$$2;
return \$this;
}
]]></content>
<tabtrigger>gsetter</tabtrigger>
<scope>source.php</scope>
</snippet>
The odd
${1/(?:^|_)(.)/\u$1/g} converts into CamelCase what you typed at memberName, uppering the first char and all that are preceded by underscore, removing the latter. So applicationName and member_name both become ApplicationName.Just go to
Tools > New Snippet, paste the code, save, and you're ready to go. Type gsetter in a PHP file, press Tab and that's all. Easy as pie.
No comments:
Post a Comment