function it_throws_for_bad_json_error(ResourceFetcher $fetcher)
 {
     $json = '{bad, josn}';
     json_decode($json);
     $error = json_last_error_msg();
     $response = new Response("data://text/plain,{$json}", 200, ['content-type' => 'application/hal+json']);
     $this->shouldThrow(ProcessingException::badJson($error))->duringProcess($response, $fetcher);
 }
Example #2
0
 /** @return Resource */
 public function process(ResponseInterface $response, ResourceFetcher $fetcher)
 {
     $this->response = $response;
     $this->fetcher = $fetcher;
     $this->data = json_decode($response->getBody());
     if ($this->data === null) {
         throw ProcessingException::badJson(json_last_error_msg());
     }
     return new Resource($this->getFields(), $this->getLinks(), $this->getResources());
 }