示例#1
0
 /**
  * @param \DCarbone\PHPFHIR\ClassGenerator\Template\Property\BasePropertyTemplate $propertyTemplate
  * @return SetterMethodTemplate
  */
 public static function createSetter(BasePropertyTemplate $propertyTemplate)
 {
     $paramTemplate = new PropertyParameterTemplate($propertyTemplate);
     if ($propertyTemplate->isCollection()) {
         $methodBody = sprintf('$this->%s[] = %s;', $propertyTemplate->getName(), NameUtils::getPropertyVariableName($paramTemplate->getProperty()->getName()));
     } else {
         $methodBody = sprintf('$this->%s = %s;', $propertyTemplate->getName(), NameUtils::getPropertyVariableName($paramTemplate->getProperty()->getName()));
     }
     $setterTemplate = new SetterMethodTemplate($propertyTemplate);
     $setterTemplate->addParameter($paramTemplate);
     $setterTemplate->addLineToBody($methodBody);
     return $setterTemplate;
 }
 /**
  * @return string
  */
 public function getParamDocBlockFragment()
 {
     $property = $this->getProperty();
     return sprintf('@param %s%s%s %s', $property->isPrimitive() || $property->isList() ? '' : '\\', $property->getPHPType(), $property->isCollection() ? '[]' : '', NameUtils::getPropertyVariableName($property->getName()));
 }
 /**
  * @return string
  */
 public function compileTemplate()
 {
     return sprintf("    /**\n%s     * @var %s%s%s\n     */\n    %s %s = %s;\n\n", $this->getDocBlockDocumentationFragment(), $this->isPrimitive() || $this->isList() ? '' : '\\', $this->getPHPType(), $this->isCollection() ? '[]' : '', (string) $this->getScope(), NameUtils::getPropertyVariableName($this->getName()), $this->isCollection() ? 'array()' : $this->determineDefaultValueOutput());
 }
 /**
  * @return string
  */
 public function compileTemplate()
 {
     if (is_string($this->defaultValue)) {
         return sprintf('%s = %s', NameUtils::getPropertyVariableName($this->getName()), $this->getDefaultValue());
     }
     return NameUtils::getPropertyVariableName($this->getName());
 }