public function getMatchingStatements(Statement $statement, Node $graph = null, array $options = [])
    {
        if (null !== $graph) {
            $graphUri = $graph->getUri();

        // no graph information given, use default graph
        } elseif (null === $graph && null === $statement->getGraph()) {
            $graphUri = 'http://saft/defaultGraph/';

        // no graph given, use graph information from $statement
        } elseif (null === $graph && $statement->getGraph()->isNamed()) {
            $graphUri = $statement->getGraph()->getUri();

        // no graph given, use graph information from $statement
        } elseif (null === $graph && false == $statement->getGraph()->isNamed()) {
            $graphUri = 'http://saft/defaultGraph/';
        }

        if (false == isset($this->statements[$graphUri])) {
            $this->statements[$graphUri] = [];
        }

        // if not default graph was requested
        if ('http://saft/defaultGraph/' != $graphUri) {
            return new StatementSetResultImpl($this->statements[$graphUri]);

        // if default graph was requested, return matching statements from all graphs
        } else {
            $_statements = [];

            foreach ($this->statements as $graphUri => $statements) {
                foreach ($statements as $statement) {
                    if ('http://saft/defaultGraph/' == $graphUri) {
                        $graph = null;
                    } else {
                        $graph = $this->nodeFactory->createNamedNode($graphUri);
                    }

                    $_statements[] = $this->statementFactory->createStatement(
                        $statement->getSubject(),
                        $statement->getPredicate(),
                        $statement->getObject(),
                        $graph
                    );
                }
            }

            return new StatementSetResultImpl($_statements);
        }
    }
public function getMatchingStatements(Statement $statement, Node $graph = null, array $options = [])
    {
        if (null !== $graph) {
            $graphUri = $graph->getUri();

        // no graph information given, use default graph
        } elseif (null === $graph && null === $statement->getGraph()) {
            $graphUri = 'http://saft/defaultGraph/';

        // no graph given, use graph information from $statement
        } elseif (null === $graph && $statement->getGraph()->isNamed()) {
            $graphUri = $statement->getGraph()->getUri();

        // no graph given, use graph information from $statement
        } elseif (null === $graph && false == $statement->getGraph()->isNamed()) {
            $graphUri = 'http://saft/defaultGraph/';
        }

        if (false == isset($this->statements[$graphUri])) {
            $this->statements[$graphUri] = [];
        }

        // if not default graph was requested
        if ('http://saft/defaultGraph/' != $graphUri) {
            return new StatementSetResultImpl($this->statements[$graphUri]);

        // if default graph was requested, return matching statements from all graphs
        } else {
            $_statements = [];

            foreach ($this->statements as $graphUri => $statements) {
                foreach ($statements as $statement) {
                    if ('http://saft/defaultGraph/' == $graphUri) {
                        $graph = null;
                    } else {
                        $graph = $this->nodeFactory->createNamedNode($graphUri);
                    }

                    $_statements[] = $this->statementFactory->createStatement(
                        $statement->getSubject(),
                        $statement->getPredicate(),
                        $statement->getObject(),
                        $graph
                    );
                }
            }

            return new StatementSetResultImpl($_statements);
        }
    }
public function getMatchingStatements ( Statement $ statement , Node $ graph = null , array $ options = [ ] ) { if ( null !== $ graph ) { $ graphUri = $ graph -> getUri ( ) ; // no graph information given, use default graph } elseif ( null === $ graph && null === $ statement -> getGraph ( ) ) { $ graphUri = 'http://saft/defaultGraph/' ; // no graph given, use graph information from $statement } elseif ( null === $ graph && $ statement -> getGraph ( ) -> isNamed ( ) ) { $ graphUri = $ statement -> getGraph ( ) -> getUri ( ) ; // no graph given, use graph information from $statement } elseif ( null === $ graph && false == $ statement -> getGraph ( ) -> isNamed ( ) ) { $ graphUri = 'http://saft/defaultGraph/' ; } if ( false == isset ( $ this -> statements [ $ graphUri ] ) ) { $ this -> statements [ $ graphUri ] = [ ] ; } // if not default graph was requested if ( 'http://saft/defaultGraph/' != $ graphUri ) { return new StatementSetResultImpl ( $ this -> statements [ $ graphUri ] ) ; // if default graph was requested, return matching statements from all graphs } else { $ _statements = [ ] ; foreach ( $ this -> statements as $ graphUri => $ statements ) { foreach ( $ statements as $ statement ) { if ( 'http://saft/defaultGraph/' == $ graphUri ) { $ graph = null ; } else { $ graph = $ this -> nodeFactory -> createNamedNode ( $ graphUri ) ; } $ _statements [ ] = $ this -> statementFactory -> createStatement ( $ statement -> getSubject ( ) , $ statement -> getPredicate ( ) , $ statement -> getObject ( ) , $ graph ) ; } } return new StatementSetResultImpl ( $ _statements ) ; } }
It basically returns all stored statements.

@param Statement $statement it can be either a concrete or pattern-statement
@param Node      $graph     optional Overrides target graph. If set, you will get all
matching statements of that graph.
@param array     $options   optional It contains key-value pairs and should provide additional
introductions for the store and/or its adapter(s)

@return SetResult it contains Statement instances of all matching statements of the given graph
It basically returns all stored statements .