Skip to content

Commit d671b08

Browse files
authored
Merge pull request #9 from Jeckel-Lab/update-abstract-handler
Update abstract handler
2 parents 9d25f4f + 2118635 commit d671b08

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/CommandHandler/CommandHandlerAbstract.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
namespace JeckelLab\CommandDispatcher\CommandHandler;
99

1010
use JeckelLab\CommandDispatcher\Command\CommandInterface;
11+
use JeckelLab\CommandDispatcher\CommandResponse\CommandResponse;
12+
use JeckelLab\CommandDispatcher\CommandResponse\CommandResponseInterface;
1113
use 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
}

0 commit comments

Comments
 (0)