/** * Parses a given string and returns an iterator containing Statement instances representing the * previously read data. * * @param string $inputString Data string containing RDF serialized data. * @param string $baseUri The base URI of the parsed content. If this URI is null the * inputStreams URL is taken as base URI. * @param string $serialization The serialization of the inputStream. If null is given the * parser will either apply some standard serialization, or the * only one it is supporting, or will try to guess the correct * serialization, or will throw an Exception. * For more information have a look here: * http://safting.github.io/doc/phpframework/data/ * @return StatementIterator StatementIterator instaince containing all the Statements parsed by the * parser to far * @throws \Exception If the base URI $baseUri is no valid URI. */ public function parseStringToIterator($inputString, $baseUri = null, $serialization = null) { $graph = new Graph(); // let EasyRdf guess the format if ($serialization === null) { $serialization = Format::guessFormat($inputString); } else { $serialization = Format::getFormat($serialization); } // if format is still null, throw exception, because we dont know what format the given stream is if (null === $serialization) { throw new \Exception('Either given $serialization is unknown or the parser could not guess the format.'); } $graph->parse($inputString, $serialization->getName()); // transform parsed data to PHP array return $this->rdfPhpToStatementIterator($graph->toRdfPhp()); }