File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 88namespace JeckelLab \CommandDispatcher \CommandHandler ;
99
1010use JeckelLab \CommandDispatcher \Command \CommandInterface ;
11+ use JeckelLab \CommandDispatcher \CommandResponse \CommandResponse ;
12+ use JeckelLab \CommandDispatcher \CommandResponse \CommandResponseInterface ;
1113use JeckelLab \CommandDispatcher \Exception \InvalidCommandException ;
1214
1315/**
@@ -32,4 +34,25 @@ protected function validateCommand(CommandInterface $command): void
3234 get_class ($ command )
3335 ));
3436 }
37+
38+ /**
39+ * @param CommandInterface $command
40+ * @return CommandResponseInterface
41+ */
42+ public function __invoke (CommandInterface $ command ): CommandResponseInterface
43+ {
44+ $ this ->validateCommand ($ command );
45+
46+ return $ this ->process ($ command , new CommandResponse ());
47+ }
48+
49+ /**
50+ * @param CommandInterface $command
51+ * @param CommandResponseInterface $commandResponse
52+ * @return CommandResponseInterface
53+ */
54+ abstract protected function process (
55+ CommandInterface $ command ,
56+ CommandResponseInterface $ commandResponse
57+ ): CommandResponseInterface ;
3558}
You can’t perform that action at this time.
0 commit comments