Skip to content

Commit 0cadce7

Browse files
author
Enno Woortmann
committed
Fix naming for merged properties with an $id field (fixes #23)
1 parent 1c5a9bb commit 0cadce7

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
/failed-classes/
44
/vendor/
55
.idea
6+
.phpunit.result.cache
67
composer.lock

src/Utils/ClassNameGenerator.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,16 @@ public function getClassName(
2222
bool $isMergeClass,
2323
string $currentClassName = ''
2424
): string {
25+
$json = $isMergeClass && isset($schema->getJson()['propertySchema'])
26+
? $schema->getJson()['propertySchema']->getJson()
27+
: $schema->getJson();
28+
2529
$className = sprintf(
2630
$isMergeClass ? '%s_Merged_%s' : '%s_%s',
2731
$currentClassName,
2832
ucfirst(
29-
isset($schema->getJson()['$id'])
30-
? str_replace('#', '', $schema->getJson()['$id'])
33+
isset($json['$id'])
34+
? str_replace('#', '', $json['$id'])
3135
: ($propertyName . ($currentClassName ? uniqid() : ''))
3236
)
3337
);

0 commit comments

Comments
 (0)