Util
in package
Provides static factory methods for plug&play parsers/serializers creation.
Tags
Table of Contents
Methods
- getParser() : ParserInterface
- Returns a parser object for a given format or file name (in the latter case the match is based on the file name extension).
- getSerializer() : SerializerInterface
- Returns a serializer object for a given format or file name (in the latter case the match is based on the file name extenstion).
- parse() : QuadIteratorInterface
- serialize() : string|null
Methods
getParser()
Returns a parser object for a given format or file name (in the latter case the match is based on the file name extension).
public
static getParser(string $formatOrFilename, DataFactoryInterface $dataFactory[, string|null $baseUri = null ]) : ParserInterface
Parameters
- $formatOrFilename : string
- $dataFactory : DataFactoryInterface
- $baseUri : string|null = null
Return values
ParserInterfacegetSerializer()
Returns a serializer object for a given format or file name (in the latter case the match is based on the file name extenstion).
public
static getSerializer(string $formatOrFilename) : SerializerInterface
Use a special value of jsonld-stream
to get the JsonLdStreamSerializer
serializer.
Parameters
- $formatOrFilename : string
Return values
SerializerInterfaceparse()
public
static parse(ResponseInterface|StreamInterface|resource|string $input, DataFactoryInterface $dataFactory[, string $format = null ][, string $baseUri = null ]) : QuadIteratorInterface
Parameters
- $input : ResponseInterface|StreamInterface|resource|string
-
Input to be parsed as RDF. In case of a string value
fopen($input, 'r')
is called first and when it fails, the value is treated as RDF. Format is detected automatically. - $dataFactory : DataFactoryInterface
- $format : string = null
-
Allows to explicitly specify format. Required if the $input is a non-seekable stream.
- $baseUri : string = null
-
Allows to explicitly specify the baseUri if it's needed and can't be guesed from the $input.
Tags
Return values
QuadIteratorInterfaceserialize()
public
static serialize(Traversable<string|int, QuadInterface>|array<string|int, QuadInterface> $data, string $format[, resource|StreamInterface|string|null $output = null ][, RdfNamespaceInterface|null $nmsp = null ]) : string|null
Parameters
- $data : Traversable<string|int, QuadInterface>|array<string|int, QuadInterface>
- $format : string
-
A mime type, file extension HTTP Accept header value or file name indicating the output format.
- $output : resource|StreamInterface|string|null = null
-
Output to write to. String value is taken as a path passed to
fopen($output, 'wb')
. If null, output as string is provided as function return value. - $nmsp : RdfNamespaceInterface|null = null
-
An optional RdfNamespace object driving namespace aliases creation. It can be used for compacting for the JsonLD serialization, just in such a case remember to register aliases for full URIs instead of for namespaces.