message = $msg; $this->level = $level; } /** * Render message. * * @return string * * @since 1.0.0 */ public function serialize() : string { return $this->__toString(); } /** * {@inheritdoc} */ public function jsonSerialize() : mixed { return $this->toArray(); } /** * {@inheritdoc} */ public function unserialize(mixed $raw) : void { if (!\is_string($raw)) { return; } $unserialized = \json_decode($raw, true); if (!\is_array($unserialized)) { return; } $this->delay = $unserialized['time'] ?? 0; $this->stay = $unserialized['stay'] ?? 0; $this->message = $unserialized['msg'] ?? ''; $this->title = $unserialized['title'] ?? ''; $this->level = $unserialized['level'] ?? 0; } /** * Stringify. * * @return string * * @since 1.0.0 */ public function __toString() { return (string) \json_encode($this->toArray()); } /** * Generate message array. * * @return array * * @since 1.0.0 */ public function toArray() : array { return [ 'type' => self::TYPE, 'time' => $this->delay, 'stay' => $this->stay, 'msg' => $this->message, 'title' => $this->title, 'level' => $this->level, ]; } }