List<PhpProperty> required = phpClass.getRequiredProperties();
if (!required.isEmpty()) {
List<Argument> args = new ArrayList<>();
for (PhpProperty property : required) {
args.add(new Argument(property.getTypeHint(), property.getName()));
}
code.appendPhpDocVars(required);
code.startFunction("__construct", args);
{
for (PhpProperty property : required) {
code.appendLine("$this->" + property.getSetterName() + "($" + property.getName() + ");");
}
}
code.endFunction();
}
code.appendLine("");
for (PhpProperty phpProperty : phpClass.getProperties()) {
code.appendPhpDocReturn(phpProperty.getTypeHint());
code.startFunction(phpProperty.getGetterName(), Collections.<Argument>emptyList());
code.appendLine("return $this->" + phpProperty.getName() + ";");
code.endFunction();
code.appendPhpDocParam("value", phpProperty);
if (phpProperty.getExplicitNamespace() == null) {
code.startFunction(phpProperty.getSetterName(), Arrays.asList(new Argument(phpProperty.getTypeHint(), "value")));
code.appendLine("$this->" + phpProperty.getName() + " = $value;");
code.endFunction();
} else {
code.startFunction(phpProperty.getSetterName(), Arrays.asList(new Argument(phpProperty.getTypeHint(), "value")));
code.appendLine("$this->" + phpProperty.getName() + " = array_map(function($item) {");
code.appendLine(" if ($item instanceof \\SoapVar) {");
code.appendLine(" return $item;");
code.appendLine(" } else {");
code.appendLine(" return new \\SoapVar($item, SOAP_ENC_OBJECT, \"" + phpProperty.getName() + "\", \"" + phpProperty.getExplicitNamespace() + "\", null, \"" + phpProperty.getExplicitNamespace() + "\");");