vscode-php-getters-setters
vscode-php-getters-setters copied to clipboard
Generate CamelCased Methods
This is such a nice extension!
I think it should generate camelCased methods, or at least have an option to enable this feature. Example:
protected $user_name;
should generate methods public function setUserName($name) public function getUserName()
Thanks for the feedback. Definitely a great addition for those cases where you cannot use camel cased var names.
Workaround using templates.
https://github.com/phproberto/vscode-php-getters-setters#custom-templates
setter.js
module.exports = (property) => `
/**
* ${property.setterDescription()}
*
* @param ${property.getType() ? property.getType() : 'mixed'} \$${property.getName()} ${property.getDescription() ? property.getDescription() : ''}
*
* @return self
*/
public function ${property.setterName().replace(/_([A-Za-z])/g, function (g) { return g[1].toUpperCase(); })}(${property.getTypeHint() ? property.getTypeHint() + ' ' : '' }\$${property.getName()})
{
$this->${property.getName()} = \$${property.getName()};
return $this;
}
`
getter.js
module.exports = (property) => `
/**
* ${property.getterDescription()}
*
* @return ${property.getType() ? property.getType() : 'mixed'}
*/
public function ${property.getterName().replace(/_([A-Za-z])/g, function (g) { return g[1].toUpperCase(); })}()
{
return $this->${property.getName()};
}
`
@diego-vieira thanks, i'am looking for that..