method = $method; $rd->params = $params; $rd->timestamp = time(); $rd->requestInfo = $request->getInfo(); $rd->requestHeaders = $request->getHeaders(); $rd->responseBody = (string)$response->getBody(); $rd->responseHeaders = $response->getHeaders(); return $rd; } public static function fromArray(array $array): RequestData { $rd = new RequestData(); $rd->method = $array['method']??'n/a'; $rd->params = $array['params']??[]; $rd->timestamp = $array['request']['timestamp']??null; $rd->requestInfo = $array['request']['info']??[]; $rd->requestHeaders = $array['request']['headers']??[]; $rd->responseBody = $array['response']['body']??null; $rd->responseHeaders = $array['response']['headers']??[]; return $rd; } public function jsonSerialize(): mixed { return [ 'method' => $this->method, 'params' => $this->params, 'request' => [ 'url' => $this->requestUrl, 'timestamp' => $this->timestamp, 'info' => $this->requestInfo, 'headers' => $this->requestHeaders, ], 'response' => [ 'status' => $this->responseStatus, 'headers' => $this->responseHeaders, 'body' => $this->responseBody, ] ]; } }