Skip to content

Commit c215450

Browse files
committed
Allow easier resultset customization
1 parent a66475b commit c215450

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/InfluxDB/Driver/Guzzle.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,17 @@ public function query()
9494

9595
$raw = (string) $response->getBody();
9696

97-
return new ResultSet($raw);
97+
return $this->asResultSet($raw);
98+
}
9899

100+
/**
101+
* @param $raw
102+
* @return ResultSet
103+
* @throws \InfluxDB\Client\Exception
104+
*/
105+
protected function asResultSet($raw)
106+
{
107+
return new ResultSet($raw);
99108
}
100109

101110
/**

src/InfluxDB/ResultSet.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,20 @@ class ResultSet
3030
public function __construct($raw)
3131
{
3232
$this->rawResults = $raw;
33-
$this->parsedResults = json_decode((string) $raw, true);
33+
$this->parsedResults = json_decode((string)$raw, true);
3434

3535
if (json_last_error() !== JSON_ERROR_NONE) {
3636
throw new \InvalidArgumentException('Invalid JSON');
3737
}
3838

39+
$this->validate();
40+
}
41+
42+
/**
43+
* @throws ClientException
44+
*/
45+
protected function validate()
46+
{
3947
// There was an error in the query thrown by influxdb
4048
if (isset($this->parsedResults['error'])) {
4149
throw new ClientException($this->parsedResults['error']);

0 commit comments

Comments
 (0)