The doc comment class-string<CreatableFromArray>|class-string<T> at position 0 could not be parsed: Unknown type name 'class-string' at position 0 in class-string<CreatableFromArray>|class-string<T>.
Loading history...
19
*
20
* @return mixed|T
21
*/
22
public function hydrate(ResponseInterface $response, string $class)
23
{
24
$body = $response->getBody()->__toString();
25
if (\mb_strpos($response->getHeaderLine('Content-Type'), 'application/json') !== 0) {
26
throw new HydrationException(sprintf('The ModelHydrator cannot hydrate response with Content-Type: %s', $response->getHeaderLine('Content-Type')));
27
}
28
29
try {
30
$data = JSON::decode($body);
31
} catch (\JsonException $e) {
32
throw new HydrationException(\sprintf('Error (%d) when trying to json_decode response', $e->getCode()));
33
}
34
35
if (\is_subclass_of($class, CreatableFromArray::class)) {