status_code = $status; $this->message = $message; $this->timestamp = date('Y-m-d H:i:s'); } /** * Get extra parameters for message response. * @return mixed */ public function getExtraParam(string $name) { return isset($this->extraParams[$name]) ? $this->extraParams[$name] : ''; } /** * Add extra parameters for message response. * @param string $name * @param mixed $value * @return void */ public function addExtraParam(string $name, $value): void { $this->extraParams[$name] = $value; } /** * Function getPayloadString * * @param string $operation * @return string */ public function getPayloadString($operation) { $res = "<$operation>\n"; $res .= "" . $this->status_code . ""; $res .= "" . $this->message . ""; $res .= "" . $this->timestamp . ""; $res .= "<$operation>"; return $res; } /** * Function getPayloadArray * * @return array */ public function getPayloadArray() { return ["status_code" => $this->status_code, 'message' => $this->message, 'timestamp' => $this->timestamp]; } }