Initial commit
This commit is contained in:
41
src/Context.php
Normal file
41
src/Context.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace NoccyLabs\React\CommandBus;
|
||||
|
||||
|
||||
/**
|
||||
* The context contains all the data relating to calling a command. It has an
|
||||
* unique identifier, the command to call, and the payload data.
|
||||
*
|
||||
*/
|
||||
class Context
|
||||
{
|
||||
|
||||
/** @var string $commandName The command name to call */
|
||||
private string $commandName;
|
||||
|
||||
/** @var array<string,mixed> The payload data */
|
||||
private array $payload = [];
|
||||
|
||||
public function __construct(string $commandName, array $payload)
|
||||
{
|
||||
$this->commandName = $commandName;
|
||||
$this->payload = $payload;
|
||||
}
|
||||
|
||||
public function getCommandName(): string
|
||||
{
|
||||
return $this->commandName;
|
||||
}
|
||||
|
||||
public function getPayload(): array
|
||||
{
|
||||
return $this->payload;
|
||||
}
|
||||
|
||||
public function __get($name)
|
||||
{
|
||||
return $this->payload[$name] ?? null;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user