public function extractQuads($query)
    {
        $quads = [];

        /**
         * Matches the following pattern: Graph <http://uri/> { ?s ?p ?o }
         * Whereas ?s ?p ?o stands for any triple, so also for an URI. It also matches multi line strings
         * which have { and triple on different lines.
         */
        $result = preg_match_all('/GRAPH\s*\<(.*?)\>\s*\{\n*\s*(.*?)\s*\n*\}/si', $query, $matches);

        // if no errors occour and graphs and triple where found
        if (false !== $result
            && true === isset($matches[1])
            && true === isset($matches[2])) {
            foreach ($matches[1] as $key => $graph) {
                // parse according triple string, for instance: <http://saft/test/s1> dc:p1 <http://saft/test/o1>
                // and extract S, P and O.
                $triplePattern = $this->extractTriplePattern($matches[2][$key]);

                // TODO Handle case that more than one triple pattern was found

                if (0 == count($triplePattern)) {
                    throw new \Exception('Quad related part of the query is invalid: '.$matches[2][$key]);
                }

                $quad = $triplePattern[0];
                $quad['g'] = $graph;
                $quad['g_type'] = 'uri';

                $quads[] = $quad;
            }
        }

        return $quads;
    }