@@ -25,7 +25,7 @@ public function generate(string $namespace, string $destinationPath)
2525 $ codePrinter = new Standard ();
2626 $ schemaClassNameMap = [];
2727 foreach ($ this ->spec ->components ->schemas as $ name => $ schema ) {
28- $ schemaClassName = trim ( str_replace ([ ' { ' , ' } ' ], [ ' Cb ' , ' Rcb ' ], ( new Convert ( $ name ))-> toPascal ()) );
28+ $ schemaClassName = $ this -> className ( $ name );
2929 if (strlen ($ schemaClassName ) === 0 ) {
3030 continue ;
3131 }
@@ -46,7 +46,7 @@ public function generate(string $namespace, string $destinationPath)
4646 }
4747
4848 foreach ($ this ->spec ->paths as $ path => $ pathItem ) {
49- $ pathClassName = str_replace ([ ' { ' , ' } ' ], [ ' Cb ' , ' Rcb ' ], ( new Convert ( $ path ))-> toPascal () );
49+ $ pathClassName = $ this -> className ( $ path );
5050 @mkdir (dirname ($ destinationPath . '/Path/ ' . $ pathClassName ), 0777 , true );
5151 file_put_contents ($ destinationPath . '/Path/ ' . $ pathClassName . '.php ' , $ codePrinter ->prettyPrintFile ([
5252 Path::generate (
@@ -58,7 +58,7 @@ public function generate(string $namespace, string $destinationPath)
5858 ),
5959 ]) . PHP_EOL );
6060 foreach ($ pathItem ->getOperations () as $ method => $ operation ) {
61- $ operationClassName = ( new Convert ($ operation ->operationId ))->fromTrain ()->toPascal ();
61+ $ operationClassName = $ this -> className (( new Convert ($ operation ->operationId ))->fromTrain ()->toPascal () );
6262 $ operations [$ method ] = $ operationClassName ;
6363
6464 @mkdir (dirname ($ destinationPath . '/Operation/ ' . $ operationClassName ), 0777 , true );
@@ -75,4 +75,9 @@ public function generate(string $namespace, string $destinationPath)
7575 }
7676
7777 }
78+
79+ private function className (string $ className ): string
80+ {
81+ return str_replace (['{ ' , '} ' , '- ' ], ['Cb ' , 'Rcb ' , 'Dash ' ], (new Convert ($ className ))->toPascal ());
82+ }
7883}
0 commit comments