| Total Complexity | 3 | 
| Total Lines | 46 | 
| Duplicated Lines | 0 % | 
| Changes | 0 | ||
| 1 | <?php | ||
| 9 | class Event implements JsonSerializable, Stringable | ||
| 10 | { | ||
| 11 | /** | ||
| 12 | * @var string | ||
| 13 | */ | ||
| 14 | private $sName; | ||
| 15 | |||
| 16 | /** | ||
| 17 | * @var Call | ||
| 18 | */ | ||
| 19 | private $xHandler; | ||
| 20 | |||
| 21 | /** | ||
| 22 | * The constructor. | ||
| 23 | * | ||
| 24 | * @param string $sName The event name | ||
| 25 | * @param Call $xHandler The event handler | ||
| 26 | */ | ||
| 27 | public function __construct(string $sName, Call $xHandler) | ||
| 28 |     { | ||
| 29 | $this->sName = $sName; | ||
| 30 | $this->xHandler = $xHandler; | ||
| 31 | } | ||
| 32 | |||
| 33 | /** | ||
| 34 | * Convert this call to array, when converting the response into json. | ||
| 35 | * | ||
| 36 | * @return array | ||
| 37 | */ | ||
| 38 | public function jsonSerialize(): array | ||
| 39 |     { | ||
| 40 | return [ | ||
| 41 | '_type' => 'event', | ||
| 42 | '_name' => $this->sName, | ||
| 43 | 'func' => $this->xHandler->jsonSerialize(), | ||
| 44 | ]; | ||
| 45 | } | ||
| 46 | |||
| 47 | /** | ||
| 48 | * Returns a string representation of this call | ||
| 49 | * | ||
| 50 | * @return string | ||
| 51 | */ | ||
| 52 | public function __toString(): string | ||
| 55 | } | ||
| 56 | } | ||
| 57 |