Skip to content

Commit 2e4b643

Browse files
committed
feat: add getters and setters for php
1 parent 4690460 commit 2e4b643

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

templates/cli/lib/commands/types.js.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ const typesCommand = actionRunner(async (rawOutputDirectory, {language}) => {
114114
}
115115
}
116116

117-
success();
117+
success(`Generated types for all the listed collections`);
118118
});
119119

120120
const types = new Command("types")

templates/cli/lib/type-generation/languages/php.js.twig

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ namespace Appwrite\\Models;
4242
4343
class <%- toPascalCase(collection.name) %> {
4444
<% for (const attribute of collection.attributes ){ -%>
45-
public <%- getType(attribute) %> $<%- toCamelCase(attribute.key) %>;
45+
private <%- getType(attribute) %> $<%- toCamelCase(attribute.key) %>;
4646
<% } -%>
4747
4848
public function __construct(
@@ -58,6 +58,16 @@ class <%- toPascalCase(collection.name) %> {
5858
$this-><%- toCamelCase(attribute.key) %> = $<%- toCamelCase(attribute.key) %>;
5959
<% } -%>
6060
}
61+
62+
<% for (const attribute of collection.attributes ){ -%>
63+
public function get<%- toPascalCase(attribute.key) %>(): <%- getType(attribute) %> {
64+
return $this-><%- toCamelCase(attribute.key) %>;
65+
}
66+
67+
public function set<%- toPascalCase(attribute.key) %>(<%- getType(attribute) %> $<%- toCamelCase(attribute.key) %>): void {
68+
$this-><%- toCamelCase(attribute.key) %> = $<%- toCamelCase(attribute.key) %>;
69+
}
70+
<% } -%>
6171
}`;
6272
}
6373

0 commit comments

Comments
 (0)