Skip to content

Commit 75c152c

Browse files
authored
Merge pull request #10 from php-api-clients/no-ghost-classes
No Ghost classes
2 parents 1ba68c0 + 29bfa28 commit 75c152c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/Generator.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,14 @@ public function generate(string $namespace, string $destinationPath)
2525
$codePrinter = new Standard();
2626
$schemaClassNameMap = [];
2727
foreach ($this->spec->components->schemas as $name => $schema) {
28-
$schemaClassNameMap[spl_object_hash($schema)] = str_replace(['{', '}'], ['Cb', 'Rcb'], (new Convert($name))->toPascal());
28+
$schemaClassName = trim(str_replace(['{', '}'], ['Cb', 'Rcb'], (new Convert($name))->toPascal()));
29+
if (strlen($schemaClassName) === 0) {
30+
continue;
31+
}
32+
$schemaClassNameMap[spl_object_hash($schema)] = $schemaClassName;
2933
}
3034
foreach ($this->spec->components->schemas as $name => $schema) {
31-
$schemaClassName = str_replace(['{', '}'], ['Cb', 'Rcb'], (new Convert($name))->toPascal());
35+
$schemaClassName = $schemaClassNameMap[spl_object_hash($schema)];
3236
@mkdir(dirname($destinationPath . '/Schema/' . $schemaClassName), 0777, true);
3337
file_put_contents($destinationPath . '/Schema/' . $schemaClassName . '.php', $codePrinter->prettyPrintFile([
3438
Schema::generate(

0 commit comments

Comments
 (0)