/** * @param string $key * @param $value * @return Response * @throws RequestException */ public function set(string $key, $value) : self { if (is_object($value)) { // Convert object to array $value = json_decode(json_encode($value), true); } if (!is_scalar($value) && !is_array($value) && !is_null($value)) { throw RequestException::setBadData(__METHOD__, $key, gettype($value)); } $this->count++; $this->data[$key] = $value; return $this; }