public function unserialize($class)
{
$request = $this->application['request'];
$accepted = explode(',', $request->headers->get('Content-Type'));
foreach ($accepted as $accept) {
if ($format = $request->getFormat(trim($accept))) {
break;
}
}
if (!in_array($format, $expected = array('json', 'xml'))) {
throw new BadRequestHttpException(sprintf('Cannot deserialize from format "%s". Expected %s', $format, implode(' or ', $expected)));
}
return $this->application['serializer']->deserialize($request->getContent(), 'Alex\\BehatLauncher\\Behat\\Run', $format);
}