Skip to content

Instantly share code, notes, and snippets.

@klfman
Last active October 4, 2017 09:49
Show Gist options
  • Save klfman/412d6589921b643b33fb4f7ebfeba36a to your computer and use it in GitHub Desktop.
Save klfman/412d6589921b643b33fb4f7ebfeba36a to your computer and use it in GitHub Desktop.
<?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