@@ -25,7 +25,7 @@ public function generate(string $namespace, string $destinationPath)
25
25
$ codePrinter = new Standard ();
26
26
$ schemaClassNameMap = [];
27
27
foreach ($ this ->spec ->components ->schemas as $ name => $ schema ) {
28
- $ schemaClassName = trim ( str_replace ([ ' { ' , ' } ' ], [ ' Cb ' , ' Rcb ' ], ( new Convert ( $ name ))-> toPascal ()) );
28
+ $ schemaClassName = $ this -> className ( $ name );
29
29
if (strlen ($ schemaClassName ) === 0 ) {
30
30
continue ;
31
31
}
@@ -46,7 +46,7 @@ public function generate(string $namespace, string $destinationPath)
46
46
}
47
47
48
48
foreach ($ this ->spec ->paths as $ path => $ pathItem ) {
49
- $ pathClassName = str_replace ([ ' { ' , ' } ' ], [ ' Cb ' , ' Rcb ' ], ( new Convert ( $ path ))-> toPascal () );
49
+ $ pathClassName = $ this -> className ( $ path );
50
50
@mkdir (dirname ($ destinationPath . '/Path/ ' . $ pathClassName ), 0777 , true );
51
51
file_put_contents ($ destinationPath . '/Path/ ' . $ pathClassName . '.php ' , $ codePrinter ->prettyPrintFile ([
52
52
Path::generate (
@@ -58,7 +58,7 @@ public function generate(string $namespace, string $destinationPath)
58
58
),
59
59
]) . PHP_EOL );
60
60
foreach ($ pathItem ->getOperations () as $ method => $ operation ) {
61
- $ operationClassName = ( new Convert ($ operation ->operationId ))->fromTrain ()->toPascal ();
61
+ $ operationClassName = $ this -> className (( new Convert ($ operation ->operationId ))->fromTrain ()->toPascal () );
62
62
$ operations [$ method ] = $ operationClassName ;
63
63
64
64
@mkdir (dirname ($ destinationPath . '/Operation/ ' . $ operationClassName ), 0777 , true );
@@ -75,4 +75,9 @@ public function generate(string $namespace, string $destinationPath)
75
75
}
76
76
77
77
}
78
+
79
+ private function className (string $ className ): string
80
+ {
81
+ return str_replace (['{ ' , '} ' , '- ' ], ['Cb ' , 'Rcb ' , 'Dash ' ], (new Convert ($ className ))->toPascal ());
82
+ }
78
83
}
0 commit comments