message = $message; if (is_int($code) || is_string($code)) { $this->code = $code; } if (is_array($positionalParameters)) { $this->positionalParameters = $positionalParameters; $this->setPositionalParameterToString(); } if (is_string($request)) { $this->request = $request; } if (is_string($response)) { $this->response = $response; } } /** * Get request data. * * @return string JSON request */ public function getRequest() { return $this->request; } /** * Get response data. * * @return string JSON response */ public function getResponse() { return $this->response; } /** * Replace positional parameter with a string * * @return void */ private function setPositionalParameterToString() { if (preg_match_all('/%\d/', $this->message, $matches)) { /* Found positional parameters */ $index = 0; foreach ($matches[0] as $occurence) { $replaceWith = $this->positionalParameters[$index]; $this->message = str_replace($occurence, $replaceWith, $this->message); $index++; } } } }