Last active
October 4, 2017 09:49
-
-
Save klfman/412d6589921b643b33fb4f7ebfeba36a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
#if (${Namespace}) | |
namespace ${Namespace}; | |
#end | |
#parse("PHP File Header") | |
#set($setter = "set" + $FieldName.substring(0,1).toUpperCase() + $FieldName.substring(1)) | |
class ${NAME} implements \JsonSerializable | |
{ | |
/** | |
* @var string | |
*/ | |
protected ${DS}${FieldName}; | |
/** | |
* Name constructor. | |
* | |
* @param string ${DS}${FieldName} | |
*/ | |
public function __construct(string ${DS}${FieldName}) | |
{ | |
${DS}this->$setter(${DS}${FieldName}); | |
} | |
/** | |
* @param string ${DS}${FieldName} | |
*/ | |
protected function $setter(string ${DS}${FieldName}) | |
{ | |
${DS}this->${FieldName} = ${DS}${FieldName}; | |
} | |
/** | |
* @return string | |
*/ | |
public function __toString(): string | |
{ | |
return ${DS}this->${FieldName}; | |
} | |
/** | |
* @return string | |
*/ | |
public function jsonSerialize() | |
{ | |
return ${DS}this->${FieldName}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment