Skip to content

Commit cb99ede

Browse files
authored
Merge pull request #16 from php-api-clients/improvement-hydrate-class-constant
Add hydrate class constant to resource interface
2 parents 32d13bc + dd434bb commit cb99ede

File tree

4 files changed

+19
-0
lines changed

4 files changed

+19
-0
lines changed

src/FileGenerators/InterfaceGenerator.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,19 @@ public function generate(): Node
6363
$class = $factory->interface($className)
6464
->extend('ResourceInterface');
6565

66+
$class->addStmt(
67+
new Node\Stmt\ClassConst(
68+
[
69+
new Node\Const_(
70+
'HYDRATE_CLASS',
71+
new Node\Scalar\String_(
72+
$this->yaml['class']
73+
)
74+
)
75+
]
76+
)
77+
);
78+
6679
foreach ($this->yaml['properties'] as $name => $details) {
6780
$type = $details;
6881
if (is_array($details)) {

tests/expected-app/src/Resources/Project/BuildInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
interface BuildInterface extends ResourceInterface
1010
{
11+
const HYDRATE_CLASS = 'Project\\Build';
12+
1113
/**
1214
* @return int
1315
*/

tests/expected-app/src/Resources/Project/ConfigInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
interface ConfigInterface extends ResourceInterface
88
{
9+
const HYDRATE_CLASS = 'Project\\Config';
10+
911
/**
1012
* @return string
1113
*/

tests/expected-app/src/Resources/ProjectInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
interface ProjectInterface extends ResourceInterface
1010
{
11+
const HYDRATE_CLASS = 'Project';
12+
1113
/**
1214
* @return int
1315
*/

0 commit comments

Comments
 (0)