/** * Executes the given SPARQL query. * * @param string|QueryBuilder $query * @return array * @throws InvalidArgumentException * @throws RangeException * @throws RuntimeException */ public function execute($query) { if ($query instanceof QueryBuilder) { $query = $query->getSPARQL(); } if (!is_string($query)) { throw new InvalidArgumentException('$query has to be a string or an instance of QueryBuilder'); } return json_decode($this->http->request($this->url, array($this->options['queryParam'] => $query, $this->options['formatParam'] => 'json')), true); }
public function testRequestFails() { $http = new Http('Asparagus Test/Asparagus 0.1'); $this->setExpectedException('RuntimeException', null, 404); $http->request('http://wikidata-mobile.wmflabs.org/not-existing-file.php'); }
private function getResult($query) { $result = $this->http->request($this->url, array($this->options['queryParam'] => $query, $this->options['formatParam'] => 'json')); return json_decode($result, true); }