From 63b8bb4b893bbc23d33591ce5b2a5ed831e63f03 Mon Sep 17 00:00:00 2001 From: Walter Dal Mut Date: Fri, 12 Jun 2015 07:57:26 +0200 Subject: [PATCH] Fixes minor violations * Removed unsed `use` statemment * Moved helper http url composer to `GuzzleAdapter` (responsibility) * Removed unused `clearTimePrecision` method * Updated composer --- composer.lock | 46 +++++++++++++++++------------------ src/Adapter/GuzzleAdapter.php | 26 ++++++++++++++++++-- src/Adapter/UdpAdapter.php | 1 - src/Client.php | 15 ------------ src/Options.php | 22 ----------------- 5 files changed, 47 insertions(+), 63 deletions(-) diff --git a/composer.lock b/composer.lock index 805bb9737a..40b847c1f0 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "96faa156d58fde5c5c3cf3df60d74ae1", + "hash": "61a6988d1b757bb9d3a074d156d73f9d", "packages": [ { "name": "guzzlehttp/guzzle", @@ -685,16 +685,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "2.1.3", + "version": "2.1.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "28a6b34e91d789b2608072ab3c82eaae7cdb973c" + "reference": "be2286cb8c7e1773eded49d9719219e6f74f9e3e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/28a6b34e91d789b2608072ab3c82eaae7cdb973c", - "reference": "28a6b34e91d789b2608072ab3c82eaae7cdb973c", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/be2286cb8c7e1773eded49d9719219e6f74f9e3e", + "reference": "be2286cb8c7e1773eded49d9719219e6f74f9e3e", "shasum": "" }, "require": { @@ -743,7 +743,7 @@ "testing", "xunit" ], - "time": "2015-06-03 07:01:01" + "time": "2015-06-09 13:05:42" }, { "name": "phpunit/php-file-iterator", @@ -931,16 +931,16 @@ }, { "name": "phpunit/phpunit", - "version": "4.6.10", + "version": "4.7.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "7b5fe98b28302a8b25693b2298bca74463336975" + "reference": "41fea1e84ed84d373f5ac099a1276c4358c90708" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/7b5fe98b28302a8b25693b2298bca74463336975", - "reference": "7b5fe98b28302a8b25693b2298bca74463336975", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/41fea1e84ed84d373f5ac099a1276c4358c90708", + "reference": "41fea1e84ed84d373f5ac099a1276c4358c90708", "shasum": "" }, "require": { @@ -951,7 +951,7 @@ "ext-spl": "*", "php": ">=5.3.3", "phpspec/prophecy": "~1.3,>=1.3.1", - "phpunit/php-code-coverage": "~2.0,>=2.0.11", + "phpunit/php-code-coverage": "~2.1", "phpunit/php-file-iterator": "~1.4", "phpunit/php-text-template": "~1.2", "phpunit/php-timer": "~1.0", @@ -973,7 +973,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.6.x-dev" + "dev-master": "4.7.x-dev" } }, "autoload": { @@ -999,20 +999,20 @@ "testing", "xunit" ], - "time": "2015-06-03 05:03:30" + "time": "2015-06-11 16:20:25" }, { "name": "phpunit/phpunit-mock-objects", - "version": "2.3.3", + "version": "2.3.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "253c005852591fd547fc18cd5b7b43a1ec82d8f7" + "reference": "92408bb1968a81b3217a6fdf6c1a198da83caa35" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/253c005852591fd547fc18cd5b7b43a1ec82d8f7", - "reference": "253c005852591fd547fc18cd5b7b43a1ec82d8f7", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/92408bb1968a81b3217a6fdf6c1a198da83caa35", + "reference": "92408bb1968a81b3217a6fdf6c1a198da83caa35", "shasum": "" }, "require": { @@ -1054,7 +1054,7 @@ "mock", "xunit" ], - "time": "2015-05-29 05:19:18" + "time": "2015-06-11 15:55:48" }, { "name": "pimple/pimple", @@ -1475,16 +1475,16 @@ }, { "name": "symfony/yaml", - "version": "v2.7.0", + "version": "v2.7.1", "source": { "type": "git", "url": "https://github.com/symfony/Yaml.git", - "reference": "4a29a5248aed4fb45f626a7bbbd330291492f5c3" + "reference": "9808e75c609a14f6db02f70fccf4ca4aab53c160" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/4a29a5248aed4fb45f626a7bbbd330291492f5c3", - "reference": "4a29a5248aed4fb45f626a7bbbd330291492f5c3", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/9808e75c609a14f6db02f70fccf4ca4aab53c160", + "reference": "9808e75c609a14f6db02f70fccf4ca4aab53c160", "shasum": "" }, "require": { @@ -1520,7 +1520,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2015-05-02 15:21:08" + "time": "2015-06-10 15:30:22" }, { "name": "zeptech/annotations", diff --git a/src/Adapter/GuzzleAdapter.php b/src/Adapter/GuzzleAdapter.php index 96b861158d..2f5509bd9c 100644 --- a/src/Adapter/GuzzleAdapter.php +++ b/src/Adapter/GuzzleAdapter.php @@ -34,7 +34,7 @@ class GuzzleAdapter extends AdapterAbstract implements QueryableInterface "body" => json_encode($message) ]; - $endpoint = $this->getOptions()->getHttpSeriesEndpoint(); + $endpoint = $this->getHttpSeriesEndpoint(); return $this->httpClient->post($endpoint, $httpMessage); } @@ -53,7 +53,29 @@ class GuzzleAdapter extends AdapterAbstract implements QueryableInterface private function get(array $httpMessage) { - $endpoint = $this->getOptions()->getHttpQueryEndpoint(); + $endpoint = $this->getHttpQueryEndpoint(); return $this->httpClient->get($endpoint, $httpMessage)->json(); } + + protected function getHttpSeriesEndpoint() + { + return sprintf( + "%s://%s:%d/write", + $this->getOptions()->getProtocol(), + $this->getOptions()->getHost(), + $this->getOptions()->getPort() + ); + } + + protected function getHttpQueryEndpoint($name = false) + { + $url = sprintf( + "%s://%s:%d/query", + $this->getOptions()->getProtocol(), + $this->getOptions()->getHost(), + $this->getOptions()->getPort() + ); + + return $url; + } } diff --git a/src/Adapter/UdpAdapter.php b/src/Adapter/UdpAdapter.php index 06477ed3b1..bc9004ee30 100644 --- a/src/Adapter/UdpAdapter.php +++ b/src/Adapter/UdpAdapter.php @@ -2,7 +2,6 @@ namespace InfluxDB\Adapter; use DateTime; -use InfluxDB\Options; final class UdpAdapter extends AdapterAbstract { diff --git a/src/Client.php b/src/Client.php index e9f7c7d896..e1537ee844 100644 --- a/src/Client.php +++ b/src/Client.php @@ -3,7 +3,6 @@ namespace InfluxDB; use InfluxDb\Adapter\QueryableInterface; -use InfluxDB\Filter\FilterInterface; /** * Client to manage request at InfluxDB @@ -70,18 +69,4 @@ class Client } return $this->getAdapter()->query("drop database \"{$name}\""); } - - private function clearTimePrecision($timePrecision) - { - switch ($timePrecision) { - case 's': - case 'u': - case 'ms': - break; - default: - $timePrecision = false; - } - - return $timePrecision; - } } diff --git a/src/Options.php b/src/Options.php index 1d030f8dbb..c472c52351 100644 --- a/src/Options.php +++ b/src/Options.php @@ -125,26 +125,4 @@ class Options $this->database = $database; return $this; } - - public function getHttpSeriesEndpoint() - { - return sprintf( - "%s://%s:%d/write", - $this->getProtocol(), - $this->getHost(), - $this->getPort() - ); - } - - public function getHttpQueryEndpoint($name = false) - { - $url = sprintf( - "%s://%s:%d/query", - $this->getProtocol(), - $this->getHost(), - $this->getPort() - ); - - return $url; - } }