data[$id] ?? null; } /** * Add response. * * @param mixed $key Response id * @param mixed $response Response to add * @param bool $overwrite Overwrite * * @return void * * @since 1.0.0 */ public function set(mixed $key, mixed $response, bool $overwrite = false) : void { $this->data[$key] = $response; } /** * {@inheritdoc} */ public function jsonSerialize() : mixed { return $this->toArray(); } /** * Generate response array from views. * * @return array * * @throws \Exception * * @since 1.0.0 */ abstract public function toArray() : array; /** * Get response language. * * @return string * * @since 1.0.0 */ public function getLanguage() : string { if (!isset($this->header)) { return ISO639x1Enum::_EN; } return $this->header->l11n->language; } /** * Get response body. * * @param bool $optimize Optimize response / minify * * @return string * * @since 1.0.0 */ abstract public function getBody(bool $optimize = false) : string; }