From abd72a5c884720bf60103cfee7be935461904bc7 Mon Sep 17 00:00:00 2001 From: Stephen Hoogendijk Date: Mon, 29 Jun 2015 10:20:47 +0200 Subject: [PATCH] Added code coverage to travis.yml; performance optimizations --- .travis.yml | 7 + composer.json | 72 +++--- composer.lock | 522 +++++++++++++++++++++++++++++++++++++++- src/InfluxDB/Client.php | 45 ++-- 4 files changed, 580 insertions(+), 66 deletions(-) diff --git a/.travis.yml b/.travis.yml index f662d47f6..658574be2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,3 +7,10 @@ php: install: - composer install + +addons: + code_climate: + repo_token: 57c4c4c0438b86b58a4bbf5e3bcba3065ff66300b75d2569bdf6cab204b9af4a + +after_script: + - vendor/bin/test-reporter \ No newline at end of file diff --git a/composer.json b/composer.json index 7512221b5..ef938be87 100644 --- a/composer.json +++ b/composer.json @@ -1,35 +1,43 @@ { - "name": "leaseweb/influxdb-php", - "description": "InfluxDB client library for PHP", - "keywords": ["influxdb", "client", "time series" , "influxdb client", "influxdb class", "influxdb library"], - "minimum-stability": "dev", - "authors": [ - { - "name": "Stephen Hoogendijk", - "email": "stephen@tca0.nl" - } - ], - "require": { - "php": ">=5.3", - "guzzlehttp/guzzle": "3.*", - "symfony/event-dispatcher": "2.*" - }, - "scripts": { - "post-install-cmd": [ - - ], - "post-update-cmd": [ - - ] - }, - "autoload": { - "psr-4" : { - "InfluxDB\\": "src/InfluxDB" - } - }, - "autoload-dev": { - "psr-4": { - "InfluxDB\\Test\\": "tests" - } + "name": "leaseweb/influxdb-php", + "description": "InfluxDB client library for PHP", + "keywords": [ + "influxdb", + "client", + "time series", + "influxdb client", + "influxdb class", + "influxdb library" + ], + "minimum-stability": "dev", + "authors": [ + { + "name": "Stephen Hoogendijk", + "email": "stephen@tca0.nl" } + ], + "require": { + "php": ">=5.3", + "guzzlehttp/guzzle": "3.*", + "symfony/event-dispatcher": "2.*" + }, + "require-dev": { + "codeclimate/php-test-reporter": "dev-master" + }, + "scripts": { + "post-install-cmd": [ + ], + "post-update-cmd": [ + ] + }, + "autoload": { + "psr-4": { + "InfluxDB\\": "src/InfluxDB" + } + }, + "autoload-dev": { + "psr-4": { + "InfluxDB\\Test\\": "tests" + } + } } diff --git a/composer.lock b/composer.lock index af32ca7fa..f763d3938 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "a6eb628e2e801a1d6843522d3da94713", + "hash": "534e09decc695b11790460256bba5ac3", "packages": [ { "name": "guzzlehttp/guzzle", @@ -157,10 +157,526 @@ "time": "2015-06-24 15:32:32" } ], - "packages-dev": [], + "packages-dev": [ + { + "name": "codeclimate/php-test-reporter", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/codeclimate/php-test-reporter.git", + "reference": "418ae782307841ac50fe26daa4cfe04520b0de9c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/codeclimate/php-test-reporter/zipball/418ae782307841ac50fe26daa4cfe04520b0de9c", + "reference": "418ae782307841ac50fe26daa4cfe04520b0de9c", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "php": ">=5.3", + "satooshi/php-coveralls": "0.6.*", + "symfony/console": ">=2.0" + }, + "require-dev": { + "ext-xdebug": "*", + "phpunit/phpunit": "3.7.*@stable" + }, + "bin": [ + "composer/bin/test-reporter" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.1.x-dev" + } + }, + "autoload": { + "psr-0": { + "CodeClimate\\Component": "src/", + "CodeClimate\\Bundle": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Code Climate", + "email": "hello@codeclimate.com", + "homepage": "https://codeclimate.com" + } + ], + "description": "PHP client for reporting test coverage to Code Climate", + "homepage": "https://github.com/codeclimate/php-test-reporter", + "keywords": [ + "codeclimate", + "coverage" + ], + "time": "2015-04-18 14:43:54" + }, + { + "name": "guzzle/guzzle", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle3.git", + "reference": "b3f5050cb6270c7a728a0b74ac2de50a262b3e02" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle3/zipball/b3f5050cb6270c7a728a0b74ac2de50a262b3e02", + "reference": "b3f5050cb6270c7a728a0b74ac2de50a262b3e02", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "php": ">=5.3.3", + "symfony/event-dispatcher": "~2.1" + }, + "replace": { + "guzzle/batch": "self.version", + "guzzle/cache": "self.version", + "guzzle/common": "self.version", + "guzzle/http": "self.version", + "guzzle/inflection": "self.version", + "guzzle/iterator": "self.version", + "guzzle/log": "self.version", + "guzzle/parser": "self.version", + "guzzle/plugin": "self.version", + "guzzle/plugin-async": "self.version", + "guzzle/plugin-backoff": "self.version", + "guzzle/plugin-cache": "self.version", + "guzzle/plugin-cookie": "self.version", + "guzzle/plugin-curlauth": "self.version", + "guzzle/plugin-error-response": "self.version", + "guzzle/plugin-history": "self.version", + "guzzle/plugin-log": "self.version", + "guzzle/plugin-md5": "self.version", + "guzzle/plugin-mock": "self.version", + "guzzle/plugin-oauth": "self.version", + "guzzle/service": "self.version", + "guzzle/stream": "self.version" + }, + "require-dev": { + "doctrine/cache": "~1.3", + "monolog/monolog": "~1.0", + "phpunit/phpunit": "3.7.*", + "psr/log": "~1.0", + "symfony/class-loader": "~2.1", + "zendframework/zend-cache": "2.*,<2.3", + "zendframework/zend-log": "2.*,<2.3" + }, + "suggest": { + "guzzlehttp/guzzle": "Guzzle 5 has moved to a new package name. The package you have installed, Guzzle 3, is deprecated." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.9-dev" + } + }, + "autoload": { + "psr-0": { + "Guzzle": "src/", + "Guzzle\\Tests": "tests/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Guzzle Community", + "homepage": "https://github.com/guzzle/guzzle/contributors" + } + ], + "description": "PHP HTTP client. This library is deprecated in favor of https://packagist.org/packages/guzzlehttp/guzzle", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "rest", + "web service" + ], + "time": "2015-04-29 17:06:53" + }, + { + "name": "psr/log", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b", + "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b", + "shasum": "" + }, + "type": "library", + "autoload": { + "psr-0": { + "Psr\\Log\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2012-12-21 11:40:51" + }, + { + "name": "satooshi/php-coveralls", + "version": "v0.6.1", + "source": { + "type": "git", + "url": "https://github.com/satooshi/php-coveralls.git", + "reference": "dd0df95bd37a7cf5c5c50304dfe260ffe4b50760" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/satooshi/php-coveralls/zipball/dd0df95bd37a7cf5c5c50304dfe260ffe4b50760", + "reference": "dd0df95bd37a7cf5c5c50304dfe260ffe4b50760", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "ext-json": "*", + "ext-simplexml": "*", + "guzzle/guzzle": ">=3.0", + "php": ">=5.3", + "psr/log": "1.0.0", + "symfony/config": ">=2.0", + "symfony/console": ">=2.0", + "symfony/stopwatch": ">=2.2", + "symfony/yaml": ">=2.0" + }, + "require-dev": { + "apigen/apigen": "2.8.*@stable", + "pdepend/pdepend": "dev-master", + "phpmd/phpmd": "dev-master", + "phpunit/php-invoker": ">=1.1.0,<1.2.0", + "phpunit/phpunit": "3.7.*@stable", + "sebastian/finder-facade": "dev-master", + "sebastian/phpcpd": "1.4.*@stable", + "squizlabs/php_codesniffer": "1.4.*@stable", + "theseer/fdomdocument": "dev-master" + }, + "bin": [ + "composer/bin/coveralls" + ], + "type": "library", + "autoload": { + "psr-0": { + "Contrib\\Component": "src/", + "Contrib\\Bundle": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kitamura Satoshi", + "email": "with.no.parachute@gmail.com", + "homepage": "https://www.facebook.com/satooshi.jp" + } + ], + "description": "PHP client library for Coveralls API", + "homepage": "https://github.com/satooshi/php-coveralls", + "keywords": [ + "ci", + "coverage", + "github", + "test" + ], + "time": "2013-05-04 08:07:33" + }, + { + "name": "symfony/config", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/symfony/Config.git", + "reference": "511051bc12a8a49704c19565d05a8377a780cee8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Config/zipball/511051bc12a8a49704c19565d05a8377a780cee8", + "reference": "511051bc12a8a49704c19565d05a8377a780cee8", + "shasum": "" + }, + "require": { + "php": ">=5.5.9", + "symfony/filesystem": "~2.8|~3.0" + }, + "require-dev": { + "symfony/phpunit-bridge": "~2.8|~3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Config\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Config Component", + "homepage": "https://symfony.com", + "time": "2015-06-18 16:43:51" + }, + { + "name": "symfony/console", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/symfony/Console.git", + "reference": "6fb9d5a32d3330b9dd598587c52bac6fbca193fe" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Console/zipball/6fb9d5a32d3330b9dd598587c52bac6fbca193fe", + "reference": "6fb9d5a32d3330b9dd598587c52bac6fbca193fe", + "shasum": "" + }, + "require": { + "php": ">=5.5.9" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/event-dispatcher": "~2.8|~3.0", + "symfony/phpunit-bridge": "~2.8|~3.0", + "symfony/process": "~2.8|~3.0" + }, + "suggest": { + "psr/log": "For using the console logger", + "symfony/event-dispatcher": "", + "symfony/process": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Console\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Console Component", + "homepage": "https://symfony.com", + "time": "2015-06-19 15:19:52" + }, + { + "name": "symfony/filesystem", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/symfony/Filesystem.git", + "reference": "24fc9ecf8ed33772e0744397ba976cae95240a3b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Filesystem/zipball/24fc9ecf8ed33772e0744397ba976cae95240a3b", + "reference": "24fc9ecf8ed33772e0744397ba976cae95240a3b", + "shasum": "" + }, + "require": { + "php": ">=5.5.9" + }, + "require-dev": { + "symfony/phpunit-bridge": "~2.8|~3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Filesystem\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Filesystem Component", + "homepage": "https://symfony.com", + "time": "2015-06-18 16:25:07" + }, + { + "name": "symfony/stopwatch", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/symfony/Stopwatch.git", + "reference": "432f3efeed399ba42f532b86c5ce63eb0fc99a4a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Stopwatch/zipball/432f3efeed399ba42f532b86c5ce63eb0fc99a4a", + "reference": "432f3efeed399ba42f532b86c5ce63eb0fc99a4a", + "shasum": "" + }, + "require": { + "php": ">=5.5.9" + }, + "require-dev": { + "symfony/phpunit-bridge": "~2.8|~3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Stopwatch\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Stopwatch Component", + "homepage": "https://symfony.com", + "time": "2015-06-04 20:30:47" + }, + { + "name": "symfony/yaml", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/symfony/Yaml.git", + "reference": "1f19f893d8b1e8fb5dc746a0def83a058b8a9983" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/1f19f893d8b1e8fb5dc746a0def83a058b8a9983", + "reference": "1f19f893d8b1e8fb5dc746a0def83a058b8a9983", + "shasum": "" + }, + "require": { + "php": ">=5.5.9" + }, + "require-dev": { + "symfony/phpunit-bridge": "~2.8|~3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Yaml\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Yaml Component", + "homepage": "https://symfony.com", + "time": "2015-06-18 16:25:07" + } + ], "aliases": [], "minimum-stability": "dev", - "stability-flags": [], + "stability-flags": { + "codeclimate/php-test-reporter": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { diff --git a/src/InfluxDB/Client.php b/src/InfluxDB/Client.php index 6156c7d82..5158f77c5 100644 --- a/src/InfluxDB/Client.php +++ b/src/InfluxDB/Client.php @@ -112,7 +112,7 @@ class Client } // the the base URI - $this->setBaseURI(sprintf('%s://%s:%d', $this->scheme, $this->host, $this->port)); + $this->baseURI = sprintf('%s://%s:%d', $this->scheme, $this->host, $this->port); $this->httpClient = new \Guzzle\Http\Client($this->getBaseURI()); } @@ -236,11 +236,10 @@ class Client $connParams = parse_url($dsn); $schemeInfo = explode('+', $connParams['scheme']); $dbName = null; + $modifier = null; + $scheme = $schemeInfo[0]; - if (count($schemeInfo) == 1) { - $modifier = null; - $scheme = $schemeInfo[0]; - } else { + if (isset($schemeInfo[1])) { $modifier = $schemeInfo[0]; $scheme = $schemeInfo[1]; } @@ -250,10 +249,7 @@ class Client } $ssl = ($modifier && $modifier == 'https' ? true : false); - - if ($connParams['path']) { - $dbName = substr($connParams['path'], 1); - } + $dbName = ($connParams['path'] ? substr($connParams['path'], 1) : null); $client = new self( $connParams['host'], @@ -265,12 +261,7 @@ class Client $timeout ); - $return = $client; - if ($dbName) { - $return = $client->db($dbName); - } - - return $return; + return ($dbName ? $client->db($dbName) : $client); } /** * @return mixed @@ -280,14 +271,6 @@ class Client return $this->baseURI; } - /** - * @param mixed $baseURI - */ - public function setBaseURI($baseURI) - { - $this->baseURI = $baseURI; - } - /** * @return int */ @@ -296,14 +279,6 @@ class Client return $this->timeout; } - /** - * @param int $timeout - */ - public function setTimeout($timeout) - { - $this->timeout = $timeout; - } - /** * @param array $points * @@ -319,4 +294,12 @@ class Client return $names; } + + /** + * @return \Guzzle\Http\Client + */ + public function getHttpClient() + { + return $this->httpClient; + } } \ No newline at end of file