File tree Expand file tree Collapse file tree 4 files changed +20
-5
lines changed
src/Service/Generator/Normalization Expand file tree Collapse file tree 4 files changed +20
-5
lines changed Original file line number Diff line number Diff line change 22
33namespace N3XT0R \MigrationGenerator \Service \Generator \Normalization \Processors ;
44
5+ use N3XT0R \MigrationGenerator \Service \Generator \Definition \Entity \ResultEntity ;
6+
57class ConstraintProcessor implements ProcessorInterface
68{
9+ public function __invoke (ResultEntity $ result ): ResultEntity
10+ {
11+ return $ result ;
12+ }
713
814}
Original file line number Diff line number Diff line change 22
33namespace N3XT0R \MigrationGenerator \Service \Generator \Normalization \Processors ;
44
5+ use N3XT0R \MigrationGenerator \Service \Generator \Definition \Entity \ResultEntity ;
6+
57class PivotProcessor implements ProcessorInterface
68{
9+ public function __invoke (ResultEntity $ result ): ResultEntity
10+ {
11+ return $ result ;
12+ }
713
814}
Original file line number Diff line number Diff line change 66
77interface ProcessorInterface
88{
9- public function process (ResultEntity $ result ): ResultEntity ;
9+ public function __invoke (ResultEntity $ result ): ResultEntity ;
1010}
Original file line number Diff line number Diff line change 1717class SchemaNormalizationManager implements SchemaNormalizationManagerInterface
1818{
1919 /**
20- * @var ProcessorInterface[]
20+ * @var ProcessorInterface|\Closure []
2121 */
22- protected iterable $ processors = [];
22+ protected array $ processors = [];
2323
2424 /**
2525 * SchemaNormalizationManager constructor.
@@ -36,7 +36,7 @@ public function __construct(iterable $processors = [])
3636 /**
3737 * Adds a new processor to the normalization chain.
3838 */
39- public function addProcessor (ProcessorInterface |iterable $ processor ): void
39+ public function addProcessor (ProcessorInterface |\ Closure $ processor ): void
4040 {
4141 $ this ->processors [] = $ processor ;
4242 }
@@ -61,7 +61,10 @@ public function normalize(ResultEntity $result): ResultEntity
6161 {
6262 $ processors = $ this ->getProcessors ();
6363 foreach ($ processors as $ processor ) {
64- $ result = $ processor ->process ($ result );
64+ if (!is_callable ($ processor )) {
65+ throw new \LogicException ('Processor is not callable. ' );
66+ }
67+ $ result = $ processor ($ result );
6568 }
6669
6770 return $ result ;
You can’t perform that action at this time.
0 commit comments