for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace TheAentMachine\Command;
/**
* Events that have JSON payloads should extend this class.
*/
abstract class AbstractJsonEventCommand extends AbstractEventCommand
{
* @param mixed[] $payload
* @return mixed[]|null
abstract protected function executeJsonEvent(array $payload): ?array;
protected function executeEvent(?string $payload): ?string
if ($payload === null) {
throw new \InvalidArgumentException('Empty payload. JSON message expected.');
}
$data = \GuzzleHttp\json_decode($payload, true);
$result = $this->executeJsonEvent($data);
if ($result === null) {
return null;
return \GuzzleHttp\json_encode($result);