44
55namespace PhpKafka \PhpAvroSchemaGenerator \Command ;
66
7- use http \Exception \RuntimeException ;
87use PhpKafka \PhpAvroSchemaGenerator \Optimizer \FieldOrderOptimizer ;
98use PhpKafka \PhpAvroSchemaGenerator \Optimizer \FullNameOptimizer ;
9+ use PhpKafka \PhpAvroSchemaGenerator \Optimizer \PrimitiveSchemaOptimizer ;
1010use PhpKafka \PhpAvroSchemaGenerator \Registry \SchemaRegistry ;
1111use PhpKafka \PhpAvroSchemaGenerator \Merger \SchemaMerger ;
1212use Symfony \Component \Console \Command \Command ;
@@ -21,6 +21,7 @@ class SubSchemaMergeCommand extends Command
2121 protected $ optimizerOptionMapping = [
2222 'optimizeFieldOrder ' => FieldOrderOptimizer::class,
2323 'optimizeFullNames ' => FullNameOptimizer::class,
24+ 'optimizePrimitiveSchemas ' => PrimitiveSchemaOptimizer::class,
2425 ];
2526 protected function configure (): void
2627 {
@@ -48,6 +49,12 @@ protected function configure(): void
4849 null ,
4950 InputOption::VALUE_NONE ,
5051 'Remove namespaces if they are enclosed in the same namespace '
52+ )
53+ ->addOption (
54+ 'optimizePrimitiveSchemas ' ,
55+ null ,
56+ InputOption::VALUE_NONE ,
57+ 'Optimize primitive schemas with using just type as a schema '
5158 );
5259 }
5360
@@ -59,7 +66,6 @@ public function execute(InputInterface $input, OutputInterface $output): int
5966 $ templateDirectoryArg = $ input ->getArgument ('templateDirectory ' );
6067 /** @var string $outputDirectoryArg */
6168 $ outputDirectoryArg = $ input ->getArgument ('outputDirectory ' );
62- $ optimizeFullNames = (bool )$ input ->getOption ('optimizeFullNames ' );
6369
6470 $ templateDirectory = $ this ->getPath ($ templateDirectoryArg );
6571 $ outputDirectory = $ this ->getPath ($ outputDirectoryArg );
@@ -71,7 +77,7 @@ public function execute(InputInterface $input, OutputInterface $output): int
7177 $ merger = new SchemaMerger ($ registry , $ outputDirectory );
7278
7379 foreach ($ this ->optimizerOptionMapping as $ optionName => $ optimizerClass ) {
74- if (true === (bool )$ input ->getOption ($ optionName )) {
80+ if (true === (bool ) $ input ->getOption ($ optionName )) {
7581 $ merger ->addOptimizer (new $ optimizerClass ());
7682 }
7783 }
0 commit comments