protected function resolveJSONPointer(Reference $reference, $schema)
{
$pointer = $reference->getFragment();
if (empty($pointer)) {
return $schema;
}
// Separate pointer into tokens
$tokens = explode('/', $pointer);
//
array_shift($tokens);
// Unescape token
$tokens = array_map(function ($token) {
$token = str_replace('~0', '/', $token);
$token = str_replace('~1', '~', $token);
return $token;
}, $tokens);
$propertyPath = implode(".", $tokens);
$propertyAccessor = PropertyAccess::createPropertyAccessor();
return $propertyAccessor->getValue($schema, $propertyPath);
}