4
4
5
5
namespace PhpKafka \PhpAvroSchemaGenerator \Command ;
6
6
7
- use http \Exception \RuntimeException ;
8
7
use PhpKafka \PhpAvroSchemaGenerator \Optimizer \FieldOrderOptimizer ;
9
8
use PhpKafka \PhpAvroSchemaGenerator \Optimizer \FullNameOptimizer ;
9
+ use PhpKafka \PhpAvroSchemaGenerator \Optimizer \PrimitiveSchemaOptimizer ;
10
10
use PhpKafka \PhpAvroSchemaGenerator \Registry \SchemaRegistry ;
11
11
use PhpKafka \PhpAvroSchemaGenerator \Merger \SchemaMerger ;
12
12
use Symfony \Component \Console \Command \Command ;
@@ -21,6 +21,7 @@ class SubSchemaMergeCommand extends Command
21
21
protected $ optimizerOptionMapping = [
22
22
'optimizeFieldOrder ' => FieldOrderOptimizer::class,
23
23
'optimizeFullNames ' => FullNameOptimizer::class,
24
+ 'optimizePrimitiveSchemas ' => PrimitiveSchemaOptimizer::class,
24
25
];
25
26
protected function configure (): void
26
27
{
@@ -48,6 +49,12 @@ protected function configure(): void
48
49
null ,
49
50
InputOption::VALUE_NONE ,
50
51
'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 '
51
58
);
52
59
}
53
60
@@ -59,7 +66,6 @@ public function execute(InputInterface $input, OutputInterface $output): int
59
66
$ templateDirectoryArg = $ input ->getArgument ('templateDirectory ' );
60
67
/** @var string $outputDirectoryArg */
61
68
$ outputDirectoryArg = $ input ->getArgument ('outputDirectory ' );
62
- $ optimizeFullNames = (bool )$ input ->getOption ('optimizeFullNames ' );
63
69
64
70
$ templateDirectory = $ this ->getPath ($ templateDirectoryArg );
65
71
$ outputDirectory = $ this ->getPath ($ outputDirectoryArg );
@@ -71,7 +77,7 @@ public function execute(InputInterface $input, OutputInterface $output): int
71
77
$ merger = new SchemaMerger ($ registry , $ outputDirectory );
72
78
73
79
foreach ($ this ->optimizerOptionMapping as $ optionName => $ optimizerClass ) {
74
- if (true === (bool )$ input ->getOption ($ optionName )) {
80
+ if (true === (bool ) $ input ->getOption ($ optionName )) {
75
81
$ merger ->addOptimizer (new $ optimizerClass ());
76
82
}
77
83
}
0 commit comments