add enum support for model property

This commit is contained in:
wing328
2015-07-02 16:17:36 +08:00
parent 38149173ff
commit 71a22141bf
11 changed files with 93 additions and 41 deletions

View File

@@ -76,9 +76,7 @@ class {{classname}} {
// verify the required parameter '{{paramName}}' is set
if (${{paramName}} === null) {
throw new \InvalidArgumentException('Missing the required parameter ${{paramName}} when calling {{nickname}}');
>>>>>>> temporary folder setting
}
{{/required}}{{/allParams}}
}{{/required}}{{/allParams}}
// parse inputs
$resourcePath = "{{path}}";

View File

@@ -78,6 +78,10 @@ class {{classname}} implements ArrayAccess {
* @return $this
*/
public function {{setter}}(${{name}}) {
{{#isEnum}}$allowed_values = array({{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}});
if (!in_array(${{{name}}}, $allowed_values)) {
throw new \InvalidArgumentException("Invalid value for '{{name}}', must be one of {{#allowableValues}}{{#values}}'{{{this}}}'{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}");
}{{/isEnum}}
$this->{{name}} = ${{name}};
return $this;
}