예제 #1
0
파일: JsonLD.php 프로젝트: janul/JsonLD
 /**
  * Convert an array of RDF quads to a JSON-LD document
  *
  * Usage:
  *
  *     $document = JsonLD::fromRdf($quads);
  *     print(JsonLD::toString($document, true));
  *
  * It is possible to configure the conversion process by setting the options
  * parameter accordingly. Available options are:
  *
  * <dl>
  *   <dt>base</dt>
  *   <dd>The base IRI of the input document.</dd>
  *
  *   <dt>useNativeTypes</dt>
  *   <dd>If set to true, native types are used for <em>xsd:integer</em>,
  *     <em>xsd:double</em>, and <em>xsd:boolean</em>; otherwise,
  *     typed strings will be used instead.</dd>
  *
  *   <dt>useRdfType</dt>
  *   <dd>If set to true, <em>rdf:type</em> will be used instead of <em>@type</em>
  * </dl>
  *
  * The options parameter might be passed as associative array or as
  * object.
  *
  * @param Quad[]            $quads   Array of quads.
  * @param null|array|object $options Options to configure the expansion
  *                                   process.
  *
  * @return array The JSON-LD document in expanded form.
  *
  * @throws InvalidQuadException If an invalid quad was detected.
  * @throws JsonLdException      If converting the quads to a JSON-LD document failed.
  *
  * @api
  */
 public static function fromRdf(array $quads, $options = null)
 {
     $options = self::mergeOptions($options);
     $processor = new Processor($options);
     return $processor->fromRdf($quads);
 }