public function resolvePointer($jsonSchema, $uri)
    {
        $resolver = new UriResolver();
        $parsed = $resolver->parse($uri);
        if (empty($parsed['fragment'])) {
            return $jsonSchema;
        }

        $path = explode('/', $parsed['fragment']);
        while ($path) {
            $pathElement = array_shift($path);
            if (!empty($pathElement)) {
                $pathElement = str_replace('~1', '/', $pathElement);
                $pathElement = str_replace('~0', '~', $pathElement);
                if (!empty($jsonSchema->$pathElement)) {
                    $jsonSchema = $jsonSchema->$pathElement;
                } else {
                    throw new ResourceNotFoundException(
                        'Fragment "' . $parsed['fragment'] . '" not found'
                        . ' in ' . $uri
                    );
                }

                if (!is_object($jsonSchema)) {
                    throw new ResourceNotFoundException(
                        'Fragment part "' . $pathElement . '" is no object '
                        . ' in ' . $uri
                    );
                }
            }
        }

        return $jsonSchema;
    }
public function resolvePointer($jsonSchema, $uri)
    {
        $resolver = new UriResolver();
        $parsed = $resolver->parse($uri);
        if (empty($parsed['fragment'])) {
            return $jsonSchema;
        }

        $path = explode('/', $parsed['fragment']);
        while ($path) {
            $pathElement = array_shift($path);
            if (!empty($pathElement)) {
                $pathElement = str_replace('~1', '/', $pathElement);
                $pathElement = str_replace('~0', '~', $pathElement);
                if (!empty($jsonSchema->$pathElement)) {
                    $jsonSchema = $jsonSchema->$pathElement;
                } else {
                    throw new ResourceNotFoundException(
                        'Fragment "' . $parsed['fragment'] . '" not found'
                        . ' in ' . $uri
                    );
                }

                if (!is_object($jsonSchema)) {
                    throw new ResourceNotFoundException(
                        'Fragment part "' . $pathElement . '" is no object '
                        . ' in ' . $uri
                    );
                }
            }
        }

        return $jsonSchema;
    }
public function resolvePointer ( $ jsonSchema , $ uri ) { $ resolver = new UriResolver ( ) ; $ parsed = $ resolver -> parse ( $ uri ) ; if ( empty ( $ parsed [ 'fragment' ] ) ) { return $ jsonSchema ; } $ path = explode ( '/' , $ parsed [ 'fragment' ] ) ; while ( $ path ) { $ pathElement = array_shift ( $ path ) ; if ( ! empty ( $ pathElement ) ) { $ pathElement = str_replace ( '~1' , '/' , $ pathElement ) ; $ pathElement = str_replace ( '~0' , '~' , $ pathElement ) ; if ( ! empty ( $ jsonSchema -> $ pathElement ) ) { $ jsonSchema = $ jsonSchema -> $ pathElement ; } else { throw new ResourceNotFoundException ( 'Fragment "' . $ parsed [ 'fragment' ] . '" not found' . ' in ' . $ uri ) ; } if ( ! is_object ( $ jsonSchema ) ) { throw new ResourceNotFoundException ( 'Fragment part "' . $ pathElement . '" is no object ' . ' in ' . $ uri ) ; } } } return $ jsonSchema ; }
Resolve a schema based on pointer

URIs can have a fragment at the end in the format of
#/path/to/object and we are to look up the 'path' property of
the first object then the 'to' and 'object' properties.

@param object $jsonSchema JSON Schema contents
@param string $uri        JSON Schema URI

@throws ResourceNotFoundException

@return object JSON Schema after walking down the fragment pieces
Resolve a schema based on pointer