Joli\Jane\Reference\Resolver::resolveJSONPointer PHP Method

resolveJSONPointer() protected method

Resolve a JSON Pointer for a Schema
protected resolveJSONPointer ( Joli\Jane\Runtime\Reference $reference, Joli\Jane\Model\JsonSchema $schema ) : mixed
$reference Joli\Jane\Runtime\Reference
$schema Joli\Jane\Model\JsonSchema
return mixed Return the json value (deserialized) referenced
    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);
    }