diff --git a/composer.json b/composer.json index d62506d..a68e012 100644 --- a/composer.json +++ b/composer.json @@ -11,9 +11,13 @@ ], "require": { "php": ">=5.5", - "guzzlehttp/guzzle": "^6.0" + "php-http/client-implementation": "^1.0", + "php-http/discovery": "^1.0", + "psr/http-message": "^1.0" }, "require-dev": { + "guzzlehttp/psr7": "^1.3", + "php-http/mock-client": "^0.3", "phpunit/phpunit": "4.7.*", "satooshi/php-coveralls": "1.0.1" }, diff --git a/composer.lock b/composer.lock index a38159d..803836f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,45 +4,97 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "21cf5251a1eab1c731860d4365b6bb31", - "content-hash": "35166a06fdd1ab04bc07023144b50efd", + "hash": "dab07e2dae9803a2127f38152caefb21", + "content-hash": "2facf65869a72d8a332fa316e59ce361", "packages": [ { - "name": "guzzlehttp/guzzle", - "version": "6.2.1", + "name": "clue/stream-filter", + "version": "v1.3.0", "source": { "type": "git", - "url": "https://github.com/guzzle/guzzle.git", - "reference": "3f808fba627f2c5b69e2501217bf31af349c1427" + "url": "https://github.com/clue/php-stream-filter.git", + "reference": "e3bf9415da163d9ad6701dccb407ed501ae69785" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/3f808fba627f2c5b69e2501217bf31af349c1427", - "reference": "3f808fba627f2c5b69e2501217bf31af349c1427", + "url": "https://api.github.com/repos/clue/php-stream-filter/zipball/e3bf9415da163d9ad6701dccb407ed501ae69785", + "reference": "e3bf9415da163d9ad6701dccb407ed501ae69785", "shasum": "" }, "require": { - "guzzlehttp/promises": "^1.0", - "guzzlehttp/psr7": "^1.3.1", - "php": ">=5.5" + "php": ">=5.3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Clue\\StreamFilter\\": "src/" + }, + "files": [ + "src/functions.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@lueck.tv" + } + ], + "description": "A simple and modern approach to stream filtering in PHP", + "homepage": "https://github.com/clue/php-stream-filter", + "keywords": [ + "bucket brigade", + "callback", + "filter", + "php_user_filter", + "stream", + "stream_filter_append", + "stream_filter_register" + ], + "time": "2015-11-08 23:41:30" + }, + { + "name": "php-http/client-common", + "version": "v1.2.1", + "source": { + "type": "git", + "url": "https://github.com/php-http/client-common.git", + "reference": "10891ee2378bba00e27d3fc81f4f14f519ef2138" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/client-common/zipball/10891ee2378bba00e27d3fc81f4f14f519ef2138", + "reference": "10891ee2378bba00e27d3fc81f4f14f519ef2138", + "shasum": "" + }, + "require": { + "php": ">=5.4", + "php-http/httplug": "^1.0", + "php-http/message": "^1.2", + "php-http/message-factory": "^1.0", + "symfony/options-resolver": "^2.6 || ^3.0" }, "require-dev": { - "ext-curl": "*", - "phpunit/phpunit": "^4.0", - "psr/log": "^1.0" + "henrikbjorn/phpspec-code-coverage": "^1.0", + "phpspec/phpspec": "^2.4" + }, + "suggest": { + "php-http/cache-plugin": "PSR-6 Cache plugin", + "php-http/logger-plugin": "PSR-3 Logger plugin", + "php-http/stopwatch-plugin": "Symfony Stopwatch plugin" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "6.2-dev" + "dev-master": "1.3-dev" } }, "autoload": { - "files": [ - "src/functions_include.php" - ], "psr-4": { - "GuzzleHttp\\": "src/" + "Http\\Client\\Common\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -51,43 +103,47 @@ ], "authors": [ { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" } ], - "description": "Guzzle is a PHP HTTP client library", - "homepage": "http://guzzlephp.org/", + "description": "Common HTTP Client implementations and tools for HTTPlug", + "homepage": "http://httplug.io", "keywords": [ "client", - "curl", - "framework", + "common", "http", - "http client", - "rest", - "web service" + "httplug" ], - "time": "2016-07-15 17:22:37" + "time": "2016-07-26 17:48:34" }, { - "name": "guzzlehttp/promises", - "version": "1.2.0", + "name": "php-http/discovery", + "version": "v1.0.0", "source": { "type": "git", - "url": "https://github.com/guzzle/promises.git", - "reference": "c10d860e2a9595f8883527fa0021c7da9e65f579" + "url": "https://github.com/php-http/discovery.git", + "reference": "4ff7e1ac2a7fa46eb4390691f02f9b60dd97e1f6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/c10d860e2a9595f8883527fa0021c7da9e65f579", - "reference": "c10d860e2a9595f8883527fa0021c7da9e65f579", + "url": "https://api.github.com/repos/php-http/discovery/zipball/4ff7e1ac2a7fa46eb4390691f02f9b60dd97e1f6", + "reference": "4ff7e1ac2a7fa46eb4390691f02f9b60dd97e1f6", "shasum": "" }, "require": { - "php": ">=5.5.0" + "php": "^5.5 || ^7.0" }, "require-dev": { - "phpunit/phpunit": "~4.0" + "henrikbjorn/phpspec-code-coverage": "^2.0.2", + "php-http/httplug": "^1.0", + "php-http/message-factory": "^1.0", + "phpspec/phpspec": "^2.4", + "puli/composer-plugin": "1.0.0-beta10" + }, + "suggest": { + "php-http/message": "Allow to use Guzzle or Diactoros factories", + "puli/composer-plugin": "Sets up Puli which is recommended for Discovery to work. Check http://docs.php-http.org/en/latest/discovery.html for more details." }, "type": "library", "extra": { @@ -97,11 +153,8 @@ }, "autoload": { "psr-4": { - "GuzzleHttp\\Promise\\": "src/" - }, - "files": [ - "src/functions_include.php" - ] + "Http\\Discovery\\": "src/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -109,40 +162,111 @@ ], "authors": [ { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" } ], - "description": "Guzzle promises library", + "description": "Finds installed HTTPlug implementations and PSR-7 message factories", + "homepage": "http://php-http.org", "keywords": [ - "promise" + "adapter", + "client", + "discovery", + "factory", + "http", + "message", + "psr7" ], - "time": "2016-05-18 16:56:05" + "time": "2016-07-18 09:37:58" }, { - "name": "guzzlehttp/psr7", - "version": "1.3.1", + "name": "php-http/httplug", + "version": "v1.1.0", "source": { "type": "git", - "url": "https://github.com/guzzle/psr7.git", - "reference": "5c6447c9df362e8f8093bda8f5d8873fe5c7f65b" + "url": "https://github.com/php-http/httplug.git", + "reference": "1c6381726c18579c4ca2ef1ec1498fdae8bdf018" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/5c6447c9df362e8f8093bda8f5d8873fe5c7f65b", - "reference": "5c6447c9df362e8f8093bda8f5d8873fe5c7f65b", + "url": "https://api.github.com/repos/php-http/httplug/zipball/1c6381726c18579c4ca2ef1ec1498fdae8bdf018", + "reference": "1c6381726c18579c4ca2ef1ec1498fdae8bdf018", "shasum": "" }, "require": { - "php": ">=5.4.0", - "psr/http-message": "~1.0" + "php": ">=5.4", + "php-http/promise": "^1.0", + "psr/http-message": "^1.0" }, - "provide": { - "psr/http-message-implementation": "1.0" + "require-dev": { + "henrikbjorn/phpspec-code-coverage": "^1.0", + "phpspec/phpspec": "^2.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Eric GELOEN", + "email": "geloen.eric@gmail.com" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "HTTPlug, the HTTP client abstraction for PHP", + "homepage": "http://httplug.io", + "keywords": [ + "client", + "http" + ], + "time": "2016-08-31 08:30:17" + }, + { + "name": "php-http/message", + "version": "v1.3.1", + "source": { + "type": "git", + "url": "https://github.com/php-http/message.git", + "reference": "6d9c2d682dcf80cb2cc641eebc5693eacee95fa4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/message/zipball/6d9c2d682dcf80cb2cc641eebc5693eacee95fa4", + "reference": "6d9c2d682dcf80cb2cc641eebc5693eacee95fa4", + "shasum": "" + }, + "require": { + "clue/stream-filter": "^1.3", + "php": ">=5.4", + "php-http/message-factory": "^1.0.2", + "psr/http-message": "^1.0" }, "require-dev": { - "phpunit/phpunit": "~4.0" + "coduo/phpspec-data-provider-extension": "^1.0", + "ext-zlib": "*", + "guzzlehttp/psr7": "^1.0", + "henrikbjorn/phpspec-code-coverage": "^1.0", + "phpspec/phpspec": "^2.4", + "zendframework/zend-diactoros": "^1.0" + }, + "suggest": { + "ext-zlib": "Used with compressor/decompressor streams", + "guzzlehttp/psr7": "Used with Guzzle PSR-7 Factories", + "zendframework/zend-diactoros": "Used with Diactoros Factories" }, "type": "library", "extra": { @@ -152,10 +276,10 @@ }, "autoload": { "psr-4": { - "GuzzleHttp\\Psr7\\": "src/" + "Http\\Message\\": "src/" }, "files": [ - "src/functions_include.php" + "src/filters.php" ] }, "notification-url": "https://packagist.org/downloads/", @@ -164,32 +288,191 @@ ], "authors": [ { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" } ], - "description": "PSR-7 message implementation", + "description": "HTTP Message related tools", + "homepage": "http://php-http.org", "keywords": [ + "http", + "message", + "psr-7" + ], + "time": "2016-07-15 14:48:03" + }, + { + "name": "php-http/message-factory", + "version": "v1.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-http/message-factory.git", + "reference": "a478cb11f66a6ac48d8954216cfed9aa06a501a1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/message-factory/zipball/a478cb11f66a6ac48d8954216cfed9aa06a501a1", + "reference": "a478cb11f66a6ac48d8954216cfed9aa06a501a1", + "shasum": "" + }, + "require": { + "php": ">=5.4", + "psr/http-message": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "Factory interfaces for PSR-7 HTTP Message", + "homepage": "http://php-http.org", + "keywords": [ + "factory", "http", "message", "stream", "uri" ], - "time": "2016-06-24 23:00:38" + "time": "2015-12-19 14:08:53" + }, + { + "name": "php-http/mock-client", + "version": "v0.3.3", + "source": { + "type": "git", + "url": "https://github.com/php-http/mock-client.git", + "reference": "1cd3f62b102877f8af984d94345fce58605f0c96" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/mock-client/zipball/1cd3f62b102877f8af984d94345fce58605f0c96", + "reference": "1cd3f62b102877f8af984d94345fce58605f0c96", + "shasum": "" + }, + "require": { + "php": "^5.5 || ^7.0", + "php-http/client-common": "^1.0", + "php-http/discovery": "^1.0", + "php-http/httplug": "^1.0", + "php-http/message-factory": "^1.0" + }, + "provide": { + "php-http/async-client-implementation": "1.0", + "php-http/client-implementation": "1.0" + }, + "require-dev": { + "henrikbjorn/phpspec-code-coverage": "^1.0", + "phpspec/phpspec": "^2.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.4-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Mock\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "David de Boer", + "email": "david@ddeboer.nl" + } + ], + "description": "Mock HTTP client", + "homepage": "http://httplug.io", + "keywords": [ + "client", + "http", + "mock", + "psr7" + ], + "time": "2016-09-16 18:48:08" + }, + { + "name": "php-http/promise", + "version": "v1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/promise.git", + "reference": "dc494cdc9d7160b9a09bd5573272195242ce7980" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/promise/zipball/dc494cdc9d7160b9a09bd5573272195242ce7980", + "reference": "dc494cdc9d7160b9a09bd5573272195242ce7980", + "shasum": "" + }, + "require-dev": { + "henrikbjorn/phpspec-code-coverage": "^1.0", + "phpspec/phpspec": "^2.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Promise\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + }, + { + "name": "Joel Wurtz", + "email": "joel.wurtz@gmail.com" + } + ], + "description": "Promise used for asynchronous HTTP requests", + "homepage": "http://httplug.io", + "keywords": [ + "promise" + ], + "time": "2016-01-26 13:27:02" }, { "name": "psr/http-message", - "version": "1.0", + "version": "1.0.1", "source": { "type": "git", "url": "https://github.com/php-fig/http-message.git", - "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298" + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-message/zipball/85d63699f0dbedb190bbd4b0d2b9dc707ea4c298", - "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", "shasum": "" }, "require": { @@ -217,6 +500,7 @@ } ], "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", "keywords": [ "http", "http-message", @@ -225,7 +509,61 @@ "request", "response" ], - "time": "2015-05-04 20:22:00" + "time": "2016-08-06 14:39:51" + }, + { + "name": "symfony/options-resolver", + "version": "v3.1.5", + "source": { + "type": "git", + "url": "https://github.com/symfony/options-resolver.git", + "reference": "30605874d99af0cde6c41fd39e18546330c38100" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/30605874d99af0cde6c41fd39e18546330c38100", + "reference": "30605874d99af0cde6c41fd39e18546330c38100", + "shasum": "" + }, + "require": { + "php": ">=5.5.9" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.1-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\OptionsResolver\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "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 OptionsResolver Component", + "homepage": "https://symfony.com", + "keywords": [ + "config", + "configuration", + "options" + ], + "time": "2016-05-12 15:59:27" } ], "packages-dev": [ @@ -379,6 +717,64 @@ "abandoned": "guzzlehttp/guzzle", "time": "2015-03-18 18:23:50" }, + { + "name": "guzzlehttp/psr7", + "version": "1.3.1", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "5c6447c9df362e8f8093bda8f5d8873fe5c7f65b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/5c6447c9df362e8f8093bda8f5d8873fe5c7f65b", + "reference": "5c6447c9df362e8f8093bda8f5d8873fe5c7f65b", + "shasum": "" + }, + "require": { + "php": ">=5.4.0", + "psr/http-message": "~1.0" + }, + "provide": { + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "PSR-7 message implementation", + "keywords": [ + "http", + "message", + "stream", + "uri" + ], + "time": "2016-06-24 23:00:38" + }, { "name": "phpdocumentor/reflection-common", "version": "1.0", @@ -435,16 +831,16 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "3.1.0", + "version": "3.1.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "9270140b940ff02e58ec577c237274e92cd40cdd" + "reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/9270140b940ff02e58ec577c237274e92cd40cdd", - "reference": "9270140b940ff02e58ec577c237274e92cd40cdd", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/8331b5efe816ae05461b7ca1e721c01b46bafb3e", + "reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e", "shasum": "" }, "require": { @@ -476,7 +872,7 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2016-06-10 09:48:41" + "time": "2016-09-30 07:12:33" }, { "name": "phpdocumentor/type-resolver", @@ -960,22 +1356,30 @@ }, { "name": "psr/log", - "version": "1.0.0", + "version": "1.0.2", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b" + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b", - "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b", + "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", "shasum": "" }, + "require": { + "php": ">=5.3.0" + }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, "autoload": { - "psr-0": { - "Psr\\Log\\": "" + "psr-4": { + "Psr\\Log\\": "Psr/Log/" } }, "notification-url": "https://packagist.org/downloads/", @@ -989,12 +1393,13 @@ } ], "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", "keywords": [ "log", "psr", "psr-3" ], - "time": "2012-12-21 11:40:51" + "time": "2016-10-10 12:19:37" }, { "name": "satooshi/php-coveralls", @@ -1172,23 +1577,23 @@ }, { "name": "sebastian/environment", - "version": "1.3.7", + "version": "1.3.8", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "4e8f0da10ac5802913afc151413bc8c53b6c2716" + "reference": "be2c607e43ce4c89ecd60e75c6a85c126e754aea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/4e8f0da10ac5802913afc151413bc8c53b6c2716", - "reference": "4e8f0da10ac5802913afc151413bc8c53b6c2716", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/be2c607e43ce4c89ecd60e75c6a85c126e754aea", + "reference": "be2c607e43ce4c89ecd60e75c6a85c126e754aea", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^5.3.3 || ^7.0" }, "require-dev": { - "phpunit/phpunit": "~4.4" + "phpunit/phpunit": "^4.8 || ^5.0" }, "type": "library", "extra": { @@ -1218,7 +1623,7 @@ "environment", "hhvm" ], - "time": "2016-05-17 03:18:57" + "time": "2016-08-18 05:49:44" }, { "name": "sebastian/exporter", @@ -1428,16 +1833,16 @@ }, { "name": "symfony/config", - "version": "v3.1.3", + "version": "v3.1.5", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "a7630397b91be09cdd2fe57fd13612e258700598" + "reference": "949e7e846743a7f9e46dc50eb639d5fde1f53341" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/a7630397b91be09cdd2fe57fd13612e258700598", - "reference": "a7630397b91be09cdd2fe57fd13612e258700598", + "url": "https://api.github.com/repos/symfony/config/zipball/949e7e846743a7f9e46dc50eb639d5fde1f53341", + "reference": "949e7e846743a7f9e46dc50eb639d5fde1f53341", "shasum": "" }, "require": { @@ -1477,24 +1882,25 @@ ], "description": "Symfony Config Component", "homepage": "https://symfony.com", - "time": "2016-07-26 08:04:17" + "time": "2016-09-25 08:27:07" }, { "name": "symfony/console", - "version": "v3.1.3", + "version": "v3.1.5", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "f9e638e8149e9e41b570ff092f8007c477ef0ce5" + "reference": "6cb0872fb57b38b3b09ff213c21ed693956b9eb0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/f9e638e8149e9e41b570ff092f8007c477ef0ce5", - "reference": "f9e638e8149e9e41b570ff092f8007c477ef0ce5", + "url": "https://api.github.com/repos/symfony/console/zipball/6cb0872fb57b38b3b09ff213c21ed693956b9eb0", + "reference": "6cb0872fb57b38b3b09ff213c21ed693956b9eb0", "shasum": "" }, "require": { "php": ">=5.5.9", + "symfony/debug": "~2.8|~3.0", "symfony/polyfill-mbstring": "~1.0" }, "require-dev": { @@ -1537,11 +1943,68 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2016-07-26 08:04:17" + "time": "2016-09-28 00:11:12" + }, + { + "name": "symfony/debug", + "version": "v3.1.5", + "source": { + "type": "git", + "url": "https://github.com/symfony/debug.git", + "reference": "e2b3f74a67fc928adc3c1b9027f73e1bc01190a8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/debug/zipball/e2b3f74a67fc928adc3c1b9027f73e1bc01190a8", + "reference": "e2b3f74a67fc928adc3c1b9027f73e1bc01190a8", + "shasum": "" + }, + "require": { + "php": ">=5.5.9", + "psr/log": "~1.0" + }, + "conflict": { + "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" + }, + "require-dev": { + "symfony/class-loader": "~2.8|~3.0", + "symfony/http-kernel": "~2.8|~3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.1-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Debug\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "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 Debug Component", + "homepage": "https://symfony.com", + "time": "2016-09-06 11:02:40" }, { "name": "symfony/event-dispatcher", - "version": "v2.8.9", + "version": "v2.8.12", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", @@ -1601,16 +2064,16 @@ }, { "name": "symfony/filesystem", - "version": "v3.1.3", + "version": "v3.1.5", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "bb29adceb552d202b6416ede373529338136e84f" + "reference": "682fd8fdb3135fdf05fc496a01579ccf6c85c0e5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/bb29adceb552d202b6416ede373529338136e84f", - "reference": "bb29adceb552d202b6416ede373529338136e84f", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/682fd8fdb3135fdf05fc496a01579ccf6c85c0e5", + "reference": "682fd8fdb3135fdf05fc496a01579ccf6c85c0e5", "shasum": "" }, "require": { @@ -1646,7 +2109,7 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "time": "2016-07-20 05:44:26" + "time": "2016-09-14 00:18:46" }, { "name": "symfony/polyfill-mbstring", @@ -1709,7 +2172,7 @@ }, { "name": "symfony/stopwatch", - "version": "v3.1.3", + "version": "v3.1.5", "source": { "type": "git", "url": "https://github.com/symfony/stopwatch.git", @@ -1758,16 +2221,16 @@ }, { "name": "symfony/yaml", - "version": "v3.1.3", + "version": "v3.1.5", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "1819adf2066880c7967df7180f4f662b6f0567ac" + "reference": "368b9738d4033c8b93454cb0dbd45d305135a6d3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/1819adf2066880c7967df7180f4f662b6f0567ac", - "reference": "1819adf2066880c7967df7180f4f662b6f0567ac", + "url": "https://api.github.com/repos/symfony/yaml/zipball/368b9738d4033c8b93454cb0dbd45d305135a6d3", + "reference": "368b9738d4033c8b93454cb0dbd45d305135a6d3", "shasum": "" }, "require": { @@ -1803,32 +2266,33 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2016-07-17 14:02:08" + "time": "2016-09-25 08:27:07" }, { "name": "webmozart/assert", - "version": "1.0.2", + "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "30eed06dd6bc88410a4ff7f77b6d22f3ce13dbde" + "reference": "bb2d123231c095735130cc8f6d31385a44c7b308" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/30eed06dd6bc88410a4ff7f77b6d22f3ce13dbde", - "reference": "30eed06dd6bc88410a4ff7f77b6d22f3ce13dbde", + "url": "https://api.github.com/repos/webmozart/assert/zipball/bb2d123231c095735130cc8f6d31385a44c7b308", + "reference": "bb2d123231c095735130cc8f6d31385a44c7b308", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^5.3.3|^7.0" }, "require-dev": { - "phpunit/phpunit": "^4.6" + "phpunit/phpunit": "^4.6", + "sebastian/version": "^1.0.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "1.2-dev" } }, "autoload": { @@ -1852,7 +2316,7 @@ "check", "validate" ], - "time": "2015-08-24 13:29:44" + "time": "2016-08-09 15:02:57" } ], "aliases": [], diff --git a/src/AnalyticsResponse.php b/src/AnalyticsResponse.php index 03352e1..1eae984 100644 --- a/src/AnalyticsResponse.php +++ b/src/AnalyticsResponse.php @@ -2,9 +2,9 @@ namespace TheIconic\Tracking\GoogleAnalytics; +use Http\Promise\Promise; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; -use GuzzleHttp\Promise\PromiseInterface; /** * Class AnalyticsResponse @@ -40,19 +40,26 @@ class AnalyticsResponse * Gets the relevant data from the Guzzle clients. * * @param RequestInterface $request - * @param ResponseInterface|PromiseInterface $response + * @param ResponseInterface|Promise $response + * + * @throws \InvalidArgumentException + * @throws \RuntimeException */ public function __construct(RequestInterface $request, $response) { if ($response instanceof ResponseInterface) { $this->httpStatusCode = $response->getStatusCode(); - $this->responseBody = $response->getBody()->getContents(); - } elseif ($response instanceof PromiseInterface) { + $this->responseBody = (string) $response->getBody(); + } elseif ($response instanceof Promise) { $this->httpStatusCode = null; $this->responseBody = null; } else { throw new \InvalidArgumentException( - 'Second constructor argument "response" must be instance of ResponseInterface or PromiseInterface' + sprintf( + 'Second constructor argument "response" must be instance of %s or %s', + RequestInterface::class, + Promise::class + ) ); } diff --git a/src/Network/HttpClient.php b/src/Network/HttpClient.php index d20c15e..a89404b 100644 --- a/src/Network/HttpClient.php +++ b/src/Network/HttpClient.php @@ -2,13 +2,14 @@ namespace TheIconic\Tracking\GoogleAnalytics\Network; -use TheIconic\Tracking\GoogleAnalytics\AnalyticsResponse; -use GuzzleHttp\Client; -use GuzzleHttp\Psr7\Request; -use GuzzleHttp\Promise; -use GuzzleHttp\Promise\PromiseInterface; +use Http\Client\HttpAsyncClient; +use Http\Discovery\HttpAsyncClientDiscovery; +use Http\Discovery\MessageFactoryDiscovery; +use Http\Message\RequestFactory; +use Http\Promise\Promise; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; +use TheIconic\Tracking\GoogleAnalytics\AnalyticsResponse; /** * Class HttpClient @@ -23,41 +24,34 @@ class HttpClient const PHP_GA_MEASUREMENT_PROTOCOL_USER_AGENT = 'THE ICONIC GA Measurement Protocol PHP Client (https://github.com/theiconic/php-ga-measurement-protocol)'; - /** - * Timeout in seconds for the request connection and actual request execution. - * Using the same value you can find in Google's PHP Client. - */ - const REQUEST_TIMEOUT_SECONDS = 100; - /** * HTTP client. * - * @var Client + * @var HttpAsyncClient */ private $client; /** - * Holds the promises (async responses). + * HTTP request factory. * - * @var PromiseInterface[] + * @var RequestFactory */ - private static $promises = []; + private $requestFactory = null; /** - * We have to unwrap and send all promises at the end before analytics objects is destroyed. + * Holds the promises (async responses). + * + * @var Promise[] */ - public function __destruct() - { - Promise\unwrap(self::$promises); - } + private static $promises = []; /** * Sets HTTP client. * * @internal - * @param Client $client + * @param HttpAsyncClient $client */ - public function setClient(Client $client) + public function setClient(HttpAsyncClient $client) { $this->client = $client; } @@ -65,19 +59,49 @@ public function setClient(Client $client) /** * Gets HTTP client for internal class use. * - * @return Client + * @return HttpAsyncClient + * + * @throws \Http\Discovery\Exception\NotFoundException */ private function getClient() { if ($this->client === null) { // @codeCoverageIgnoreStart - $this->setClient(new Client()); + $this->setClient(HttpAsyncClientDiscovery::find()); } // @codeCoverageIgnoreEnd return $this->client; } + /** + * Sets HTTP request factory. + * + * @param RequestFactory $factory + * + * @internal + */ + public function setRequestFactory(RequestFactory $factory) + { + $this->requestFactory = $factory; + } + + /** + * Gets HTTP request factory for internal class use. + * + * @return RequestFactory + * + * @throws \Http\Discovery\Exception\NotFoundException + */ + private function getRequestFactory() + { + if (null === $this->requestFactory) { + $this->setRequestFactory(MessageFactoryDiscovery::find()); + } + + return $this->requestFactory; + } + /** * Sends request to Google Analytics. * @@ -85,20 +109,19 @@ private function getClient() * @param string $url * @param boolean $nonBlocking * @return AnalyticsResponse + * + * @throws \Exception If processing the request is impossible (eg. bad configuration). + * @throws \Http\Discovery\Exception\NotFoundException */ public function post($url, $nonBlocking = false) { - $request = new Request( + $request = $this->getRequestFactory()->createRequest( 'GET', $url, ['User-Agent' => self::PHP_GA_MEASUREMENT_PROTOCOL_USER_AGENT] ); - $response = $this->getClient()->sendAsync($request, [ - 'synchronous' => !$nonBlocking, - 'timeout' => self::REQUEST_TIMEOUT_SECONDS, - 'connect_timeout' => self::REQUEST_TIMEOUT_SECONDS, - ]); + $response = $this->getClient()->sendAsyncRequest($request); if ($nonBlocking) { self::$promises[] = $response; @@ -113,7 +136,7 @@ public function post($url, $nonBlocking = false) * Creates an analytics response object. * * @param RequestInterface $request - * @param ResponseInterface|PromiseInterface $response + * @param ResponseInterface|Promise $response * @return AnalyticsResponse */ protected function getAnalyticsResponse(RequestInterface $request, $response) diff --git a/tests/TheIconic/Tracking/GoogleAnalytics/AnalyticsResponseTest.php b/tests/TheIconic/Tracking/GoogleAnalytics/AnalyticsResponseTest.php index b3081f2..4935898 100644 --- a/tests/TheIconic/Tracking/GoogleAnalytics/AnalyticsResponseTest.php +++ b/tests/TheIconic/Tracking/GoogleAnalytics/AnalyticsResponseTest.php @@ -3,7 +3,10 @@ namespace TheIconic\Tracking\GoogleAnalytics; use GuzzleHttp\Psr7\Uri; +use Http\Promise\Promise; use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\StreamInterface; class AnalyticsResponseTest extends \PHPUnit_Framework_TestCase { @@ -29,66 +32,51 @@ class AnalyticsResponseTest extends \PHPUnit_Framework_TestCase public function setUp() { - $mockResponse = $this->getMockBuilder('GuzzleHttp\Psr7\Response') - ->setMethods(['getStatusCode', 'getBody']) - ->disableOriginalConstructor() - ->getMock(); + $mockResponse = $this->getMockForAbstractClass(ResponseInterface::class); - $mockResponse->expects($this->atLeast(1)) + $mockResponse->expects(static::atLeast(1)) ->method('getStatusCode') - ->will($this->returnValue('200')); + ->will(static::returnValue('200')); - $invalidBodyMock = $this->getMockBuilder('Psr\Http\Message\StreamInterface') - ->disableOriginalConstructor() - ->getMock(); + $invalidBodyMock = $this->getMockForAbstractClass(StreamInterface::class); - $invalidBodyMock->expects($this->any()) + $invalidBodyMock->expects(static::any()) ->method('getContents') - ->will($this->returnValue('asldkjaslkdjsadlkj')); + ->willReturn('asldkjaslkdjsadlkj'); - $mockResponse->expects($this->any()) + $mockResponse->expects(static::any()) ->method('getBody') - ->will($this->returnValue($invalidBodyMock)); + ->willReturn($invalidBodyMock); - $this->mockRequest = $this->getMockBuilder('GuzzleHttp\Psr7\Request') - ->setMethods(['getUri']) - ->disableOriginalConstructor() - ->getMock(); + $this->mockRequest = $this->getMockForAbstractClass(RequestInterface::class); - $this->mockRequest->expects($this->atLeast(1)) + $this->mockRequest->expects(static::atLeast(1)) ->method('getUri') - ->will($this->returnValue(new Uri('http://test-collector/hello'))); + ->willReturn(new Uri('http://test-collector/hello')); $this->analyticsResponse = new AnalyticsResponse($this->mockRequest, $mockResponse); - $mockResponseAsync = $this->getMockBuilder('GuzzleHttp\Promise\Promise') - ->disableOriginalConstructor() - ->getMock(); + $mockResponseAsync = $this->getMockForAbstractClass(Promise::class); $this->analyticsResponseAsync = new AnalyticsResponse($this->mockRequest, $mockResponseAsync); - $mockDebugResponse = $this->getMockBuilder('GuzzleHttp\Psr7\Response') - ->setMethods(['getStatusCode', 'getBody']) - ->disableOriginalConstructor() - ->getMock(); + $mockDebugResponse = $this->getMockForAbstractClass(ResponseInterface::class); - $mockDebugResponse->expects($this->atLeast(1)) + $mockDebugResponse->expects(static::atLeast(1)) ->method('getStatusCode') - ->will($this->returnValue('200')); + ->willReturn(200); - $bodyMock = $this->getMockBuilder('Psr\Http\Message\StreamInterface') - ->disableOriginalConstructor() - ->getMock(); + $bodyMock = $this->getMockForAbstractClass(StreamInterface::class); - $bodyMock->expects($this->atLeast(1)) - ->method('getContents') - ->will($this->returnValue('{"salutation":"hello world"}')); + $bodyMock->expects(static::atLeast(1)) + ->method('__toString') + ->willReturn('{"salutation":"hello world"}'); - $mockDebugResponse->expects($this->atLeast(1)) + $mockDebugResponse->expects(static::atLeast(1)) ->method('getBody') - ->will($this->returnValue($bodyMock)); + ->willReturn($bodyMock); $this->analyticsDebugResponse = new AnalyticsResponse($this->mockRequest, $mockDebugResponse); } @@ -103,19 +91,19 @@ public function testConstructorWithWrongResponseValue() public function testStatusCode() { - $this->assertEquals('200', $this->analyticsResponse->getHttpStatusCode()); - $this->assertEquals(null, $this->analyticsResponseAsync->getHttpStatusCode()); + static::assertEquals(200, $this->analyticsResponse->getHttpStatusCode()); + static::assertNull($this->analyticsResponseAsync->getHttpStatusCode()); } public function testGetUrl() { - $this->assertEquals('http://test-collector/hello', $this->analyticsResponse->getRequestUrl()); - $this->assertEquals('http://test-collector/hello', $this->analyticsResponseAsync->getRequestUrl()); + static::assertEquals('http://test-collector/hello', $this->analyticsResponse->getRequestUrl()); + static::assertEquals('http://test-collector/hello', $this->analyticsResponseAsync->getRequestUrl()); } public function testDebugResponse() { - $this->assertEquals(['salutation' => 'hello world'], $this->analyticsDebugResponse->getDebugResponse()); - $this->assertEquals([], $this->analyticsResponse->getDebugResponse()); + static::assertEquals(['salutation' => 'hello world'], $this->analyticsDebugResponse->getDebugResponse()); + static::assertEquals([], $this->analyticsResponse->getDebugResponse()); } } diff --git a/tests/TheIconic/Tracking/GoogleAnalytics/Network/HttpClientTest.php b/tests/TheIconic/Tracking/GoogleAnalytics/Network/HttpClientTest.php index bad81ee..3c6f5f5 100644 --- a/tests/TheIconic/Tracking/GoogleAnalytics/Network/HttpClientTest.php +++ b/tests/TheIconic/Tracking/GoogleAnalytics/Network/HttpClientTest.php @@ -2,78 +2,25 @@ namespace TheIconic\Tracking\GoogleAnalytics\Network; -use TheIconic\Tracking\GoogleAnalytics\Parameters\General\CacheBuster; -use TheIconic\Tracking\GoogleAnalytics\Tests\CompoundParameterTestCollection; -use TheIconic\Tracking\GoogleAnalytics\Tests\CompoundTestParameter; -use TheIconic\Tracking\GoogleAnalytics\Tests\SingleTestParameter; -use TheIconic\Tracking\GoogleAnalytics\Tests\SingleTestParameterIndexed; +use Http\Mock\Client; +use TheIconic\Tracking\GoogleAnalytics\AnalyticsResponse; class HttpClientTest extends \PHPUnit_Framework_TestCase { - /** - * @var HttpClient - */ - private $httpClient; - - /** - * @var HttpClient - */ - private $mockHttpClient; - - public function setUp() - { - $this->httpClient = new HttpClient(); - - $mockResponse = $this->getMockBuilder('GuzzleHttp\Psr7\Response') - ->setMethods(['getStatusCode']) - ->disableOriginalConstructor() - ->getMock(); - - $mockPromise = $this->getMockBuilder('GuzzleHttp\Promise\Promise') - ->disableOriginalConstructor() - ->getMock(); - - $mockPromise->expects($this->exactly(3)) - ->method('wait') - ->will($this->returnValue($mockResponse)); - - $guzzleClient = $this->getMockBuilder('GuzzleHttp\Client') - ->setMethods(['sendAsync']) - ->disableOriginalConstructor() - ->getMock(); - - $guzzleClient->expects($this->atLeast(1)) - ->method('sendAsync') - ->with($this->anything()) - ->will($this->returnValue($mockPromise)); - - $this->httpClient->setClient($guzzleClient); - - $this->mockHttpClient = $this->getMockBuilder('TheIconic\Tracking\GoogleAnalytics\Network\HttpClient') - ->setMethods(['getAnalyticsResponse']) - ->getMock(); - - $this->mockHttpClient->expects($this->atLeast(1)) - ->method('getAnalyticsResponse') - ->will($this->returnArgument(1)); - - $this->mockHttpClient->setClient($guzzleClient); - } - public function testPost() { - $response = $this->mockHttpClient->post('http://test-collector.com/collect?v=1'); - $this->assertInstanceOf('Psr\Http\Message\ResponseInterface', $response); + $client = new HttpClient(); - $responseAsync = $this->mockHttpClient->post('http://test-collector.com/collect?v=1', true); - $this->assertInstanceOf('GuzzleHttp\Promise\PromiseInterface', $responseAsync); + $mockClient = new Client(); - $response = $this->httpClient->post('http://test-collector.com/collect?v=1'); + $client->setClient($mockClient); - $this->assertInstanceOf('TheIconic\Tracking\GoogleAnalytics\AnalyticsResponse', $response); + $response = $client->post('http://example.com/foo'); + static::assertInstanceOf(AnalyticsResponse::class, $response); + static::assertEquals('http://example.com/foo', $response->getRequestUrl()); - // Promises should be unwrapped on the object destruction - $this->httpClient = null; - $this->mockHttpClient = null; + $response = $client->post('http://example.com/bar', true); + static::assertInstanceOf(AnalyticsResponse::class, $response); + static::assertEquals('http://example.com/bar', $response->getRequestUrl()); } }