/** * Maps a response body to an object. * * @param ResponseInterface $response * @param string $class * @param string $format * * @return object */ public function map(ResponseInterface $response, $class, $format) { if ('json' === $format) { $hal = Hal::fromJson((string) $response->getBody(), 10); } elseif ('xml' === $format) { $hal = Hal::fromXml((string) $response->getBody(), 10); } else { throw new InvalidArgumentException(sprintf('Unsupported format "%s".', $format)); } return $this->serializer->fromArray($this->getDataFromHal($hal, $class), $class); }