diff --git a/lib/InfluxPHP/BaseHTTP.php b/lib/InfluxPHP/BaseHTTP.php index 077a6d5..55efb0d 100644 --- a/lib/InfluxPHP/BaseHTTP.php +++ b/lib/InfluxPHP/BaseHTTP.php @@ -64,7 +64,7 @@ class BaseHTTP $c->children[] = $this; } - protected function getCurl($url, Array $args = []) + protected function getCurl($url, array $args = []) { $args = array_merge($args, ['u' => $this->user, 'p' => $this->pass]); $url = "http://{$this->host}:{$this->port}/{$this->base}{$url}"; @@ -77,7 +77,7 @@ class BaseHTTP protected function execCurl($ch, $json = false) { $response = curl_exec ($ch); - $status = (string)curl_getinfo($ch, CURLINFO_HTTP_CODE); + $status = (string)curl_getinfo($ch, CURLINFO_HTTP_CODE); //$type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE); curl_close($ch); if ($status[0] != 2) { @@ -115,19 +115,19 @@ class BaseHTTP } return $this; } - - throw new \InvalidArgumentException("Expecting m,s or u"); + + throw new \InvalidArgumentException("Expecting s, m or u as time precision"); } - protected function get($url, Array $args = []) + protected function get($url, array $args = []) { $ch = $this->getCurl($url, $args); return $this->execCurl($ch, true); } - protected function post($url, Array $body) + protected function post($url, array $body, array $args = []) { - $ch = $this->getCurl($url); + $ch = $this->getCurl($url, $args); curl_setopt_array($ch, [ CURLOPT_POST => 1, CURLOPT_POSTFIELDS => json_encode($body), diff --git a/lib/InfluxPHP/Cursor.php b/lib/InfluxPHP/Cursor.php index ed41aa1..60f73a6 100644 --- a/lib/InfluxPHP/Cursor.php +++ b/lib/InfluxPHP/Cursor.php @@ -41,7 +41,7 @@ use ArrayIterator; class Cursor extends ArrayIterator { - public function __construct(Array $resultset) + public function __construct(array $resultset) { $rows = []; foreach ($resultset as $set) { diff --git a/lib/InfluxPHP/DB.php b/lib/InfluxPHP/DB.php index 523023b..630b019 100644 --- a/lib/InfluxPHP/DB.php +++ b/lib/InfluxPHP/DB.php @@ -60,7 +60,7 @@ class DB extends BaseHTTP return $this->client->deleteDatabase($this->name); } - public function insert($name, Array $data) + public function insert($name, array $data) { $points = []; $first = current($data); @@ -72,7 +72,7 @@ class DB extends BaseHTTP $points[] = array_values($value); } $body = compact('name', 'columns', 'points'); - return $this->post('series', [$body]); + return $this->post('series', [$body], ['time_precision' => $this->timePrecision]); } public function first($sql) diff --git a/tests/DBTest.php b/tests/DBTest.php index b52c953..621a032 100644 --- a/tests/DBTest.php +++ b/tests/DBTest.php @@ -63,8 +63,8 @@ class DBTest extends \phpunit_framework_testcase $this->assertEquals('m', $db->getTimePrecision()); } - /** - * @expectedException InvalidArgumentException + /** + * @expectedException InvalidArgumentException */ public function testInvalidTimePrecision() { @@ -118,5 +118,5 @@ class DBTest extends \phpunit_framework_testcase } $db->drop(); - } + } }