react-command-bus/src/Context.php

42 lines
834 B
PHP

<?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;
}
}