diff --git a/.gitignore b/.gitignore index 8efa18b..34a600c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ ### Composer ### composer.phar /vendor/ +/.idea/ +/Tests/cache/ diff --git a/.travis.yml b/.travis.yml index deaa758..a3caff7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ cache: php: - 5.6 - 7.0 + - 7.1 - hhvm before_install: diff --git a/Tests/ClientTest.php b/Tests/ClientTest.php index e432bf6..686ea9f 100644 --- a/Tests/ClientTest.php +++ b/Tests/ClientTest.php @@ -4,49 +4,46 @@ use Carbon\Carbon; use TruckersMP\API\APIClient; - -use GuzzleHttp\Client as GuzzleClient; -use Http\Adapter\Guzzle6\Client as GuzzleAdapter; - -use TruckersMP\Types\Version; use TruckersMP\Types\Ban; use TruckersMP\Types\Bans; use TruckersMP\Types\Player; -use TruckersMP\Types\Servers; -use TruckersMP\Types\Server; class ClientTest extends \PHPUnit_Framework_TestCase { - private $testAccount = 585204; private $client; + /** + * ClientTest constructor. + * + */ public function __construct() { parent::__construct(); - $config = [ - - ]; - $guzzle = new GuzzleClient($config); - $adapter = new GuzzleAdapter($guzzle); - - $this->client = new APIClient($adapter); + $this->client = new APIClient(); } + /** + * @throws \Exception + * @throws \Http\Client\Exception + */ public function testPlayer() { - $player = $this->client->player($this->testAccount); // Special test account that *should* remain static + $player = $this->client->player($this->testAccount); $this->assertEquals($player->name, 'tuxytestaccount'); - $this->assertEquals($player->groupID, 1); $this->assertEquals($player->groupName, 'Player'); $this->assertInstanceOf(Player::class, $player); } + /** + * @throws \Exception + * @throws \Http\Client\Exception + */ public function testPlayerBans() { $bans = $this->client->bans($this->testAccount); @@ -57,15 +54,23 @@ public function testPlayerBans() $this->assertInstanceOf(Bans::class, $bans); $this->assertInstanceOf(Ban::class, $bans[0]); - } + /** + * @throws \Exception + * @throws \Http\Client\Exception + */ public function testServers() { $servers = $this->client->servers(); + $this->assertEquals($servers[0]->name, 'Europe 1'); } + /** + * @throws \Exception + * @throws \Http\Client\Exception + */ public function testVersion() { $version = $this->client->version(); diff --git a/composer.json b/composer.json index 342dbf1..2f6d7a8 100644 --- a/composer.json +++ b/composer.json @@ -1,52 +1,57 @@ { - "name": "truckersmp/api-client", - "description": "TruckersMP API Library helps connecting to and using the TruckersMP API.", - "homepage": "https://truckersmp.com/", - "license": "MIT", - "authors": [ - { - "name": "HumaneWolf", - "email": "humanewolf@truckersmp.com", - "homepage": "https://humanewolf.com/", - "role": "CM/Dev" - }, - { - "name": "Thor Erik (Tuxy Fluffyclaws) Lie", - "email": "tuxy@truckersmp.com", - "homepage": "https://truckersmp.com/", - "role": "Dev" - } - ], - "require": { - "php": ">=5.6.0", - "nesbot/carbon": "^1.21", - "php-http/client-implementation": "^1.0", - "php-http/message": "^1.2", - "guzzlehttp/psr7": "^1.3" + "name": "truckersmp/api-client", + "description": "TruckersMP API Library helps connecting to and using the TruckersMP API.", + "homepage": "https://truckersmp.com/", + "license": "MIT", + "authors": [ + { + "name": "HumaneWolf", + "email": "humanewolf@truckersmp.com", + "homepage": "https://humanewolf.com/", + "role": "CM/Dev" }, - "require-dev": { - "phpunit/phpunit": "^5.3", - "squizlabs/php_codesniffer": "^2.6", - "php-http/guzzle6-adapter": "^1.0" + { + "name": "Thor Erik (Tuxy Fluffyclaws) Lie", + "email": "tuxy@truckersmp.com", + "homepage": "https://truckersmp.com/", + "role": "Dev" }, - "autoload": { - "psr-4": { - "TruckersMP\\": "src/" - }, - "classmap": [ - "src/" - ] + { + "name": "CJMAXiK", + "email": "me@cjmaxik.ru", + "homepage": "https://cjmaxik.ru", + "role": "IGA/Dev" + } + ], + "require": { + "php": ">=5.6.0", + "nesbot/carbon": "^1.21", + "php-http/message": "^1.2", + "guzzlehttp/psr7": "^1.3" + }, + "require-dev": { + "phpunit/phpunit": "^5.3", + "squizlabs/php_codesniffer": "^2.6", + "php-http/guzzle6-adapter": "^1.0" + }, + "autoload": { + "psr-4": { + "TruckersMP\\": "src/" }, - "autoload-dev": { - "psr-4": { - "TruckersMP\\Tests\\API\\": "tests/" - } - }, - "scripts": { - "test": [ - "./vendor/bin/phpunit", - "./vendor/bin/phpcs src --standard=PSR2", - "./vendor/bin/phpcs Tests --standard=PSR2" - ] - } + "classmap": [ + "src/" + ] + }, + "autoload-dev": { + "psr-4": { + "TruckersMP\\Tests\\API\\": "tests/" + } + }, + "scripts": { + "test": [ + "./vendor/bin/phpunit", + "./vendor/bin/phpcs src --standard=PSR2", + "./vendor/bin/phpcs Tests --standard=PSR2" + ] + } } diff --git a/composer.lock b/composer.lock index c6ea915..6875e2b 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +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": "71ec3163663f18416c9bf2d1e0cb65fa", - "content-hash": "2c1d4698425cf2ca8f19291e44fd8693", + "content-hash": "b1dd8f3b08c2fbe389ccc6ed1f4f8f96", "packages": [ { "name": "clue/stream-filter", @@ -54,45 +53,45 @@ "stream_filter_append", "stream_filter_register" ], - "time": "2015-11-08 23:41:30" + "time": "2015-11-08T23:41:30+00:00" }, { - "name": "guzzlehttp/guzzle", - "version": "6.2.0", + "name": "guzzlehttp/psr7", + "version": "1.4.2", "source": { "type": "git", - "url": "https://github.com/guzzle/guzzle.git", - "reference": "d094e337976dff9d8e2424e8485872194e768662" + "url": "https://github.com/guzzle/psr7.git", + "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/d094e337976dff9d8e2424e8485872194e768662", - "reference": "d094e337976dff9d8e2424e8485872194e768662", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/f5b8a8512e2b58b0071a7280e39f14f72e05d87c", + "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c", "shasum": "" }, "require": { - "guzzlehttp/promises": "~1.0", - "guzzlehttp/psr7": "~1.1", - "php": ">=5.5.0" + "php": ">=5.4.0", + "psr/http-message": "~1.0" + }, + "provide": { + "psr/http-message-implementation": "1.0" }, "require-dev": { - "ext-curl": "*", - "phpunit/phpunit": "~4.0", - "psr/log": "~1.0" + "phpunit/phpunit": "~4.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "6.2-dev" + "dev-master": "1.4-dev" } }, "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + }, "files": [ "src/functions_include.php" - ], - "psr-4": { - "GuzzleHttp\\": "src/" - } + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -103,54 +102,56 @@ "name": "Michael Dowling", "email": "mtdowling@gmail.com", "homepage": "https://github.com/mtdowling" + }, + { + "name": "Tobias Schultze", + "homepage": "https://github.com/Tobion" } ], - "description": "Guzzle is a PHP HTTP client library", - "homepage": "http://guzzlephp.org/", + "description": "PSR-7 message implementation that also provides common utility methods", "keywords": [ - "client", - "curl", - "framework", "http", - "http client", - "rest", - "web service" + "message", + "request", + "response", + "stream", + "uri", + "url" ], - "time": "2016-03-21 20:02:09" + "time": "2017-03-20T17:10:46+00:00" }, { - "name": "guzzlehttp/promises", - "version": "1.2.0", + "name": "nesbot/carbon", + "version": "1.22.1", "source": { "type": "git", - "url": "https://github.com/guzzle/promises.git", - "reference": "c10d860e2a9595f8883527fa0021c7da9e65f579" + "url": "https://github.com/briannesbitt/Carbon.git", + "reference": "7cdf42c0b1cc763ab7e4c33c47a24e27c66bfccc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/c10d860e2a9595f8883527fa0021c7da9e65f579", - "reference": "c10d860e2a9595f8883527fa0021c7da9e65f579", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/7cdf42c0b1cc763ab7e4c33c47a24e27c66bfccc", + "reference": "7cdf42c0b1cc763ab7e4c33c47a24e27c66bfccc", "shasum": "" }, "require": { - "php": ">=5.5.0" + "php": ">=5.3.0", + "symfony/translation": "~2.6 || ~3.0" }, "require-dev": { - "phpunit/phpunit": "~4.0" + "friendsofphp/php-cs-fixer": "~2", + "phpunit/phpunit": "~4.0 || ~5.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "1.23-dev" } }, "autoload": { "psr-4": { - "GuzzleHttp\\Promise\\": "src/" - }, - "files": [ - "src/functions_include.php" - ] + "Carbon\\": "src/Carbon/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -158,53 +159,68 @@ ], "authors": [ { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" + "name": "Brian Nesbitt", + "email": "brian@nesbot.com", + "homepage": "http://nesbot.com" } ], - "description": "Guzzle promises library", + "description": "A simple API extension for DateTime.", + "homepage": "http://carbon.nesbot.com", "keywords": [ - "promise" + "date", + "datetime", + "time" ], - "time": "2016-05-18 16:56:05" + "time": "2017-01-16T07:55:07+00:00" }, { - "name": "guzzlehttp/psr7", - "version": "1.3.1", + "name": "php-http/message", + "version": "1.5.0", "source": { "type": "git", - "url": "https://github.com/guzzle/psr7.git", - "reference": "5c6447c9df362e8f8093bda8f5d8873fe5c7f65b" + "url": "https://github.com/php-http/message.git", + "reference": "13df8c48f40ca7925303aa336f19be4b80984f01" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/5c6447c9df362e8f8093bda8f5d8873fe5c7f65b", - "reference": "5c6447c9df362e8f8093bda8f5d8873fe5c7f65b", + "url": "https://api.github.com/repos/php-http/message/zipball/13df8c48f40ca7925303aa336f19be4b80984f01", + "reference": "13df8c48f40ca7925303aa336f19be4b80984f01", "shasum": "" }, "require": { - "php": ">=5.4.0", - "psr/http-message": "~1.0" - }, - "provide": { - "psr/http-message-implementation": "1.0" + "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" + "akeneo/phpspec-skip-example-extension": "^1.0", + "coduo/phpspec-data-provider-extension": "^1.0", + "ext-zlib": "*", + "guzzlehttp/psr7": "^1.0", + "henrikbjorn/phpspec-code-coverage": "^1.0", + "phpspec/phpspec": "^2.4", + "slim/slim": "^3.0", + "zendframework/zend-diactoros": "^1.0" + }, + "suggest": { + "ext-zlib": "Used with compressor/decompressor streams", + "guzzlehttp/psr7": "Used with Guzzle PSR-7 Factories", + "slim/slim": "Used with Slim Framework PSR-7 implementation", + "zendframework/zend-diactoros": "Used with Diactoros Factories" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4-dev" + "dev-master": "1.6-dev" } }, "autoload": { "psr-4": { - "GuzzleHttp\\Psr7\\": "src/" + "Http\\Message\\": "src/" }, "files": [ - "src/functions_include.php" + "src/filters.php" ] }, "notification-url": "https://packagist.org/downloads/", @@ -213,45 +229,46 @@ ], "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", - "stream", - "uri" + "psr-7" ], - "time": "2016-06-24 23:00:38" + "time": "2017-02-14T08:58:37+00:00" }, { - "name": "nesbot/carbon", - "version": "1.21.0", + "name": "php-http/message-factory", + "version": "v1.0.2", "source": { "type": "git", - "url": "https://github.com/briannesbitt/Carbon.git", - "reference": "7b08ec6f75791e130012f206e3f7b0e76e18e3d7" + "url": "https://github.com/php-http/message-factory.git", + "reference": "a478cb11f66a6ac48d8954216cfed9aa06a501a1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/7b08ec6f75791e130012f206e3f7b0e76e18e3d7", - "reference": "7b08ec6f75791e130012f206e3f7b0e76e18e3d7", + "url": "https://api.github.com/repos/php-http/message-factory/zipball/a478cb11f66a6ac48d8954216cfed9aa06a501a1", + "reference": "a478cb11f66a6ac48d8954216cfed9aa06a501a1", "shasum": "" }, "require": { - "php": ">=5.3.0", - "symfony/translation": "~2.6|~3.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.0|~5.0" + "php": ">=5.4", + "psr/http-message": "^1.0" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, "autoload": { "psr-4": { - "Carbon\\": "src/Carbon/" + "Http\\Message\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -260,56 +277,47 @@ ], "authors": [ { - "name": "Brian Nesbitt", - "email": "brian@nesbot.com", - "homepage": "http://nesbot.com" + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" } ], - "description": "A simple API extension for DateTime.", - "homepage": "http://carbon.nesbot.com", + "description": "Factory interfaces for PSR-7 HTTP Message", + "homepage": "http://php-http.org", "keywords": [ - "date", - "datetime", - "time" + "factory", + "http", + "message", + "stream", + "uri" ], - "time": "2015-11-04 20:07:17" + "time": "2015-12-19T14:08:53+00:00" }, { - "name": "php-http/guzzle6-adapter", - "version": "v1.1.1", + "name": "psr/http-message", + "version": "1.0.1", "source": { "type": "git", - "url": "https://github.com/php-http/guzzle6-adapter.git", - "reference": "a56941f9dc6110409cfcddc91546ee97039277ab" + "url": "https://github.com/php-fig/http-message.git", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-http/guzzle6-adapter/zipball/a56941f9dc6110409cfcddc91546ee97039277ab", - "reference": "a56941f9dc6110409cfcddc91546ee97039277ab", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", "shasum": "" }, "require": { - "guzzlehttp/guzzle": "^6.0", - "php": ">=5.5.0", - "php-http/httplug": "^1.0" - }, - "provide": { - "php-http/async-client-implementation": "1.0", - "php-http/client-implementation": "1.0" - }, - "require-dev": { - "ext-curl": "*", - "php-http/adapter-integration-tests": "^0.4" + "php": ">=5.3.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2-dev" + "dev-master": "1.0.x-dev" } }, "autoload": { "psr-4": { - "Http\\Adapter\\Guzzle6\\": "src/" + "Psr\\Http\\Message\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -318,55 +326,55 @@ ], "authors": [ { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com" - }, - { - "name": "David de Boer", - "email": "david@ddeboer.nl" + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" } ], - "description": "Guzzle 6 HTTP Adapter", - "homepage": "http://httplug.io", + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", "keywords": [ - "Guzzle", - "http" + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" ], - "time": "2016-05-10 06:13:32" + "time": "2016-08-06T14:39:51+00:00" }, { - "name": "php-http/httplug", - "version": "v1.0.0", + "name": "symfony/polyfill-mbstring", + "version": "v1.3.0", "source": { "type": "git", - "url": "https://github.com/php-http/httplug.git", - "reference": "2061047ca53a08a6b8f52e997b2a76f386b397dd" + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "e79d363049d1c2128f133a2667e4f4190904f7f4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-http/httplug/zipball/2061047ca53a08a6b8f52e997b2a76f386b397dd", - "reference": "2061047ca53a08a6b8f52e997b2a76f386b397dd", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/e79d363049d1c2128f133a2667e4f4190904f7f4", + "reference": "e79d363049d1c2128f133a2667e4f4190904f7f4", "shasum": "" }, "require": { - "php": ">=5.4", - "php-http/promise": "^1.0", - "psr/http-message": "^1.0" + "php": ">=5.3.3" }, - "require-dev": { - "henrikbjorn/phpspec-code-coverage": "^1.0", - "phpspec/phpspec": "^2.4" + "suggest": { + "ext-mbstring": "For best performance" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1-dev" + "dev-master": "1.3-dev" } }, "autoload": { "psr-4": { - "Http\\Client\\": "src/" - } + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -374,67 +382,69 @@ ], "authors": [ { - "name": "Eric GELOEN", - "email": "geloen.eric@gmail.com" + "name": "Nicolas Grekas", + "email": "p@tchwork.com" }, { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com" + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], - "description": "HTTPlug, the HTTP client abstraction for PHP", - "homepage": "http://httplug.io", + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", "keywords": [ - "client", - "http" + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" ], - "time": "2016-01-26 14:34:50" + "time": "2016-11-14T01:06:16+00:00" }, { - "name": "php-http/message", - "version": "v1.2.0", + "name": "symfony/translation", + "version": "v3.2.7", "source": { "type": "git", - "url": "https://github.com/php-http/message.git", - "reference": "c8fadec9533f5e34a8a730a947fa76363f3aa620" + "url": "https://github.com/symfony/translation.git", + "reference": "c740eee70783d2af4d3d6b70d5146f209e6b4d13" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-http/message/zipball/c8fadec9533f5e34a8a730a947fa76363f3aa620", - "reference": "c8fadec9533f5e34a8a730a947fa76363f3aa620", + "url": "https://api.github.com/repos/symfony/translation/zipball/c740eee70783d2af4d3d6b70d5146f209e6b4d13", + "reference": "c740eee70783d2af4d3d6b70d5146f209e6b4d13", "shasum": "" }, "require": { - "clue/stream-filter": "^1.3", - "php": ">=5.4", - "php-http/message-factory": "^1.0.2", - "psr/http-message": "^1.0" + "php": ">=5.5.9", + "symfony/polyfill-mbstring": "~1.0" + }, + "conflict": { + "symfony/config": "<2.8" }, "require-dev": { - "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" + "psr/log": "~1.0", + "symfony/config": "~2.8|~3.0", + "symfony/intl": "^2.8.18|^3.2.5", + "symfony/yaml": "~2.8|~3.0" }, "suggest": { - "ext-zlib": "Used with compressor/decompressor streams", - "guzzlehttp/psr7": "Used with Guzzle PSR-7 Factories", - "zendframework/zend-diactoros": "Used with Diactoros Factories" + "psr/log": "To use logging capability in translator", + "symfony/config": "", + "symfony/yaml": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3-dev" + "dev-master": "3.2-dev" } }, "autoload": { "psr-4": { - "Http\\Message\\": "src/" + "Symfony\\Component\\Translation\\": "" }, - "files": [ - "src/filters.php" + "exclude-from-classmap": [ + "/Tests/" ] }, "notification-url": "https://packagist.org/downloads/", @@ -443,46 +453,53 @@ ], "authors": [ { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com" + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], - "description": "HTTP Message related tools", - "homepage": "http://php-http.org", - "keywords": [ - "http", - "message", - "psr-7" - ], - "time": "2016-03-29 20:44:24" - }, + "description": "Symfony Translation Component", + "homepage": "https://symfony.com", + "time": "2017-03-21T21:44:32+00:00" + } + ], + "packages-dev": [ { - "name": "php-http/message-factory", - "version": "v1.0.2", + "name": "doctrine/instantiator", + "version": "1.0.5", "source": { "type": "git", - "url": "https://github.com/php-http/message-factory.git", - "reference": "a478cb11f66a6ac48d8954216cfed9aa06a501a1" + "url": "https://github.com/doctrine/instantiator.git", + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-http/message-factory/zipball/a478cb11f66a6ac48d8954216cfed9aa06a501a1", - "reference": "a478cb11f66a6ac48d8954216cfed9aa06a501a1", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", "shasum": "" }, "require": { - "php": ">=5.4", - "psr/http-message": "^1.0" + "php": ">=5.3,<8.0-DEV" + }, + "require-dev": { + "athletic/athletic": "~0.1.8", + "ext-pdo": "*", + "ext-phar": "*", + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "~2.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "1.0.x-dev" } }, "autoload": { "psr-4": { - "Http\\Message\\": "src/" + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" } }, "notification-url": "https://packagist.org/downloads/", @@ -491,48 +508,55 @@ ], "authors": [ { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com" + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://ocramius.github.com/" } ], - "description": "Factory interfaces for PSR-7 HTTP Message", - "homepage": "http://php-http.org", + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://github.com/doctrine/instantiator", "keywords": [ - "factory", - "http", - "message", - "stream", - "uri" + "constructor", + "instantiate" ], - "time": "2015-12-19 14:08:53" + "time": "2015-06-14T21:17:01+00:00" }, { - "name": "php-http/promise", - "version": "v1.0.0", + "name": "guzzlehttp/guzzle", + "version": "6.2.3", "source": { "type": "git", - "url": "https://github.com/php-http/promise.git", - "reference": "dc494cdc9d7160b9a09bd5573272195242ce7980" + "url": "https://github.com/guzzle/guzzle.git", + "reference": "8d6c6cc55186db87b7dc5009827429ba4e9dc006" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-http/promise/zipball/dc494cdc9d7160b9a09bd5573272195242ce7980", - "reference": "dc494cdc9d7160b9a09bd5573272195242ce7980", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/8d6c6cc55186db87b7dc5009827429ba4e9dc006", + "reference": "8d6c6cc55186db87b7dc5009827429ba4e9dc006", "shasum": "" }, + "require": { + "guzzlehttp/promises": "^1.0", + "guzzlehttp/psr7": "^1.4", + "php": ">=5.5" + }, "require-dev": { - "henrikbjorn/phpspec-code-coverage": "^1.0", - "phpspec/phpspec": "^2.4" + "ext-curl": "*", + "phpunit/phpunit": "^4.0", + "psr/log": "^1.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1-dev" + "dev-master": "6.2-dev" } }, "autoload": { + "files": [ + "src/functions_include.php" + ], "psr-4": { - "Http\\Promise\\": "src/" + "GuzzleHttp\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -541,48 +565,57 @@ ], "authors": [ { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com" - }, - { - "name": "Joel Wurtz", - "email": "joel.wurtz@gmail.com" + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" } ], - "description": "Promise used for asynchronous HTTP requests", - "homepage": "http://httplug.io", + "description": "Guzzle is a PHP HTTP client library", + "homepage": "http://guzzlephp.org/", "keywords": [ - "promise" + "client", + "curl", + "framework", + "http", + "http client", + "rest", + "web service" ], - "time": "2016-01-26 13:27:02" + "time": "2017-02-28T22:50:30+00:00" }, { - "name": "psr/http-message", - "version": "1.0", + "name": "guzzlehttp/promises", + "version": "v1.3.1", "source": { "type": "git", - "url": "https://github.com/php-fig/http-message.git", - "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298" + "url": "https://github.com/guzzle/promises.git", + "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-message/zipball/85d63699f0dbedb190bbd4b0d2b9dc707ea4c298", - "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298", + "url": "https://api.github.com/repos/guzzle/promises/zipball/a59da6cf61d80060647ff4d3eb2c03a2bc694646", + "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": ">=5.5.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.4-dev" } }, "autoload": { "psr-4": { - "Psr\\Http\\Message\\": "src/" - } + "GuzzleHttp\\Promise\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -590,125 +623,96 @@ ], "authors": [ { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" } ], - "description": "Common interface for HTTP messages", + "description": "Guzzle promises library", "keywords": [ - "http", - "http-message", - "psr", - "psr-7", - "request", - "response" + "promise" ], - "time": "2015-05-04 20:22:00" + "time": "2016-12-20T10:07:11+00:00" }, { - "name": "symfony/polyfill-mbstring", - "version": "v1.2.0", + "name": "myclabs/deep-copy", + "version": "1.6.0", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "dff51f72b0706335131b00a7f49606168c582594" + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "5a5a9fc8025a08d8919be87d6884d5a92520cefe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/dff51f72b0706335131b00a7f49606168c582594", - "reference": "dff51f72b0706335131b00a7f49606168c582594", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/5a5a9fc8025a08d8919be87d6884d5a92520cefe", + "reference": "5a5a9fc8025a08d8919be87d6884d5a92520cefe", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=5.4.0" }, - "suggest": { - "ext-mbstring": "For best performance" + "require-dev": { + "doctrine/collections": "1.*", + "phpunit/phpunit": "~4.1" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2-dev" - } - }, "autoload": { "psr-4": { - "Symfony\\Polyfill\\Mbstring\\": "" - }, - "files": [ - "bootstrap.php" - ] + "DeepCopy\\": "src/DeepCopy/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for the Mbstring extension", - "homepage": "https://symfony.com", + "description": "Create deep copies (clones) of your objects", + "homepage": "https://github.com/myclabs/DeepCopy", "keywords": [ - "compatibility", - "mbstring", - "polyfill", - "portable", - "shim" + "clone", + "copy", + "duplicate", + "object", + "object graph" ], - "time": "2016-05-18 14:26:46" + "time": "2017-01-26T22:05:40+00:00" }, { - "name": "symfony/translation", - "version": "v3.1.2", + "name": "php-http/guzzle6-adapter", + "version": "v1.1.1", "source": { "type": "git", - "url": "https://github.com/symfony/translation.git", - "reference": "d63a94528530c3ea5ff46924c8001cec4a398609" + "url": "https://github.com/php-http/guzzle6-adapter.git", + "reference": "a56941f9dc6110409cfcddc91546ee97039277ab" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/d63a94528530c3ea5ff46924c8001cec4a398609", - "reference": "d63a94528530c3ea5ff46924c8001cec4a398609", + "url": "https://api.github.com/repos/php-http/guzzle6-adapter/zipball/a56941f9dc6110409cfcddc91546ee97039277ab", + "reference": "a56941f9dc6110409cfcddc91546ee97039277ab", "shasum": "" }, "require": { - "php": ">=5.5.9", - "symfony/polyfill-mbstring": "~1.0" + "guzzlehttp/guzzle": "^6.0", + "php": ">=5.5.0", + "php-http/httplug": "^1.0" }, - "conflict": { - "symfony/config": "<2.8" + "provide": { + "php-http/async-client-implementation": "1.0", + "php-http/client-implementation": "1.0" }, "require-dev": { - "psr/log": "~1.0", - "symfony/config": "~2.8|~3.0", - "symfony/intl": "~2.8|~3.0", - "symfony/yaml": "~2.8|~3.0" - }, - "suggest": { - "psr/log": "To use logging capability in translator", - "symfony/config": "", - "symfony/yaml": "" + "ext-curl": "*", + "php-http/adapter-integration-tests": "^0.4" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.1-dev" + "dev-master": "1.2-dev" } }, "autoload": { "psr-4": { - "Symfony\\Component\\Translation\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] + "Http\\Adapter\\Guzzle6\\": "src/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -716,53 +720,54 @@ ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" }, { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" + "name": "David de Boer", + "email": "david@ddeboer.nl" } ], - "description": "Symfony Translation Component", - "homepage": "https://symfony.com", - "time": "2016-06-29 05:41:56" - } - ], - "packages-dev": [ + "description": "Guzzle 6 HTTP Adapter", + "homepage": "http://httplug.io", + "keywords": [ + "Guzzle", + "http" + ], + "time": "2016-05-10T06:13:32+00:00" + }, { - "name": "doctrine/instantiator", - "version": "1.0.5", + "name": "php-http/httplug", + "version": "v1.1.0", "source": { "type": "git", - "url": "https://github.com/doctrine/instantiator.git", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" + "url": "https://github.com/php-http/httplug.git", + "reference": "1c6381726c18579c4ca2ef1ec1498fdae8bdf018" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", + "url": "https://api.github.com/repos/php-http/httplug/zipball/1c6381726c18579c4ca2ef1ec1498fdae8bdf018", + "reference": "1c6381726c18579c4ca2ef1ec1498fdae8bdf018", "shasum": "" }, "require": { - "php": ">=5.3,<8.0-DEV" + "php": ">=5.4", + "php-http/promise": "^1.0", + "psr/http-message": "^1.0" }, "require-dev": { - "athletic/athletic": "~0.1.8", - "ext-pdo": "*", - "ext-phar": "*", - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "~2.0" + "henrikbjorn/phpspec-code-coverage": "^1.0", + "phpspec/phpspec": "^2.4" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.1-dev" } }, "autoload": { "psr-4": { - "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" + "Http\\Client\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -771,60 +776,71 @@ ], "authors": [ { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com", - "homepage": "http://ocramius.github.com/" + "name": "Eric GELOEN", + "email": "geloen.eric@gmail.com" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" } ], - "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://github.com/doctrine/instantiator", + "description": "HTTPlug, the HTTP client abstraction for PHP", + "homepage": "http://httplug.io", "keywords": [ - "constructor", - "instantiate" + "client", + "http" ], - "time": "2015-06-14 21:17:01" + "time": "2016-08-31T08:30:17+00:00" }, { - "name": "myclabs/deep-copy", - "version": "1.5.1", + "name": "php-http/promise", + "version": "v1.0.0", "source": { "type": "git", - "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "a8773992b362b58498eed24bf85005f363c34771" + "url": "https://github.com/php-http/promise.git", + "reference": "dc494cdc9d7160b9a09bd5573272195242ce7980" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/a8773992b362b58498eed24bf85005f363c34771", - "reference": "a8773992b362b58498eed24bf85005f363c34771", + "url": "https://api.github.com/repos/php-http/promise/zipball/dc494cdc9d7160b9a09bd5573272195242ce7980", + "reference": "dc494cdc9d7160b9a09bd5573272195242ce7980", "shasum": "" }, - "require": { - "php": ">=5.4.0" - }, "require-dev": { - "doctrine/collections": "1.*", - "phpunit/phpunit": "~4.1" + "henrikbjorn/phpspec-code-coverage": "^1.0", + "phpspec/phpspec": "^2.4" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, "autoload": { "psr-4": { - "DeepCopy\\": "src/DeepCopy/" + "Http\\Promise\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], - "description": "Create deep copies (clones) of your objects", - "homepage": "https://github.com/myclabs/DeepCopy", + "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": [ - "clone", - "copy", - "duplicate", - "object", - "object graph" + "promise" ], - "time": "2015-11-20 12:04:31" + "time": "2016-01-26T13:27:02+00:00" }, { "name": "phpdocumentor/reflection-common", @@ -878,20 +894,20 @@ "reflection", "static analysis" ], - "time": "2015-12-27 11:43:31" + "time": "2015-12-27T11:43:31+00:00" }, { "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": { @@ -923,20 +939,20 @@ } ], "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-30T07:12:33+00:00" }, { "name": "phpdocumentor/type-resolver", - "version": "0.2", + "version": "0.2.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "b39c7a5b194f9ed7bd0dd345c751007a41862443" + "reference": "e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/b39c7a5b194f9ed7bd0dd345c751007a41862443", - "reference": "b39c7a5b194f9ed7bd0dd345c751007a41862443", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb", + "reference": "e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb", "shasum": "" }, "require": { @@ -970,31 +986,32 @@ "email": "me@mikevanriel.com" } ], - "time": "2016-06-10 07:14:17" + "time": "2016-11-25T06:54:22+00:00" }, { "name": "phpspec/prophecy", - "version": "v1.6.1", + "version": "v1.7.0", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "58a8137754bc24b25740d4281399a4a3596058e0" + "reference": "93d39f1f7f9326d746203c7c056f300f7f126073" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/58a8137754bc24b25740d4281399a4a3596058e0", - "reference": "58a8137754bc24b25740d4281399a4a3596058e0", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/93d39f1f7f9326d746203c7c056f300f7f126073", + "reference": "93d39f1f7f9326d746203c7c056f300f7f126073", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", "php": "^5.3|^7.0", "phpdocumentor/reflection-docblock": "^2.0|^3.0.2", - "sebastian/comparator": "^1.1", - "sebastian/recursion-context": "^1.0" + "sebastian/comparator": "^1.1|^2.0", + "sebastian/recursion-context": "^1.0|^2.0|^3.0" }, "require-dev": { - "phpspec/phpspec": "^2.0" + "phpspec/phpspec": "^2.5|^3.2", + "phpunit/phpunit": "^4.8 || ^5.6.5" }, "type": "library", "extra": { @@ -1032,39 +1049,39 @@ "spy", "stub" ], - "time": "2016-06-07 08:13:47" + "time": "2017-03-02T20:05:34+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "4.0.0", + "version": "4.0.8", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "900370c81280cc0d942ffbc5912d80464eaee7e9" + "reference": "ef7b2f56815df854e66ceaee8ebe9393ae36a40d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/900370c81280cc0d942ffbc5912d80464eaee7e9", - "reference": "900370c81280cc0d942ffbc5912d80464eaee7e9", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ef7b2f56815df854e66ceaee8ebe9393ae36a40d", + "reference": "ef7b2f56815df854e66ceaee8ebe9393ae36a40d", "shasum": "" }, "require": { + "ext-dom": "*", + "ext-xmlwriter": "*", "php": "^5.6 || ^7.0", - "phpunit/php-file-iterator": "~1.3", - "phpunit/php-text-template": "~1.2", - "phpunit/php-token-stream": "^1.4.2", - "sebastian/code-unit-reverse-lookup": "~1.0", - "sebastian/environment": "^1.3.2", - "sebastian/version": "~1.0|~2.0" + "phpunit/php-file-iterator": "^1.3", + "phpunit/php-text-template": "^1.2", + "phpunit/php-token-stream": "^1.4.2 || ^2.0", + "sebastian/code-unit-reverse-lookup": "^1.0", + "sebastian/environment": "^1.3.2 || ^2.0", + "sebastian/version": "^1.0 || ^2.0" }, "require-dev": { - "ext-xdebug": ">=2.1.4", - "phpunit/phpunit": "^5.4" + "ext-xdebug": "^2.1.4", + "phpunit/phpunit": "^5.7" }, "suggest": { - "ext-dom": "*", - "ext-xdebug": ">=2.4.0", - "ext-xmlwriter": "*" + "ext-xdebug": "^2.5.1" }, "type": "library", "extra": { @@ -1095,20 +1112,20 @@ "testing", "xunit" ], - "time": "2016-06-03 05:03:56" + "time": "2017-04-02T07:44:40+00:00" }, { "name": "phpunit/php-file-iterator", - "version": "1.4.1", + "version": "1.4.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0" + "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/6150bf2c35d3fc379e50c7602b75caceaa39dbf0", - "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/3cc8f69b3028d0f96a9078e6295d86e9bf019be5", + "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5", "shasum": "" }, "require": { @@ -1142,7 +1159,7 @@ "filesystem", "iterator" ], - "time": "2015-06-21 13:08:43" + "time": "2016-10-03T07:40:28+00:00" }, { "name": "phpunit/php-text-template", @@ -1183,29 +1200,34 @@ "keywords": [ "template" ], - "time": "2015-06-21 13:50:34" + "time": "2015-06-21T13:50:34+00:00" }, { "name": "phpunit/php-timer", - "version": "1.0.8", + "version": "1.0.9", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "38e9124049cf1a164f1e4537caf19c99bf1eb260" + "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/38e9124049cf1a164f1e4537caf19c99bf1eb260", - "reference": "38e9124049cf1a164f1e4537caf19c99bf1eb260", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", + "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^5.3.3 || ^7.0" }, "require-dev": { - "phpunit/phpunit": "~4|~5" + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, "autoload": { "classmap": [ "src/" @@ -1227,20 +1249,20 @@ "keywords": [ "timer" ], - "time": "2016-05-12 18:03:57" + "time": "2017-02-26T11:10:40+00:00" }, { "name": "phpunit/php-token-stream", - "version": "1.4.8", + "version": "1.4.11", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da" + "reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da", - "reference": "3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/e03f8f67534427a787e21a385a67ec3ca6978ea7", + "reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7", "shasum": "" }, "require": { @@ -1276,50 +1298,54 @@ "keywords": [ "tokenizer" ], - "time": "2015-09-15 10:49:45" + "time": "2017-02-27T10:12:30+00:00" }, { "name": "phpunit/phpunit", - "version": "5.4.6", + "version": "5.7.19", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "2f1fc94b77ea6418bd6a06c64a1dac0645fbce59" + "reference": "69c4f49ff376af2692bad9cebd883d17ebaa98a1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/2f1fc94b77ea6418bd6a06c64a1dac0645fbce59", - "reference": "2f1fc94b77ea6418bd6a06c64a1dac0645fbce59", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/69c4f49ff376af2692bad9cebd883d17ebaa98a1", + "reference": "69c4f49ff376af2692bad9cebd883d17ebaa98a1", "shasum": "" }, "require": { "ext-dom": "*", "ext-json": "*", - "ext-pcre": "*", - "ext-reflection": "*", - "ext-spl": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-xml": "*", "myclabs/deep-copy": "~1.3", "php": "^5.6 || ^7.0", - "phpspec/prophecy": "^1.3.1", - "phpunit/php-code-coverage": "^4.0", + "phpspec/prophecy": "^1.6.2", + "phpunit/php-code-coverage": "^4.0.4", "phpunit/php-file-iterator": "~1.4", "phpunit/php-text-template": "~1.2", "phpunit/php-timer": "^1.0.6", "phpunit/phpunit-mock-objects": "^3.2", - "sebastian/comparator": "~1.1", + "sebastian/comparator": "^1.2.4", "sebastian/diff": "~1.2", - "sebastian/environment": "^1.3 || ^2.0", - "sebastian/exporter": "~1.2", - "sebastian/global-state": "~1.0", - "sebastian/object-enumerator": "~1.0", + "sebastian/environment": "^1.3.4 || ^2.0", + "sebastian/exporter": "~2.0", + "sebastian/global-state": "^1.1", + "sebastian/object-enumerator": "~2.0", "sebastian/resource-operations": "~1.0", - "sebastian/version": "~1.0|~2.0", + "sebastian/version": "~1.0.3|~2.0", "symfony/yaml": "~2.1|~3.0" }, "conflict": { "phpdocumentor/reflection-docblock": "3.0.2" }, + "require-dev": { + "ext-pdo": "*" + }, "suggest": { + "ext-xdebug": "*", "phpunit/php-invoker": "~1.1" }, "bin": [ @@ -1328,7 +1354,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "5.4.x-dev" + "dev-master": "5.7.x-dev" } }, "autoload": { @@ -1354,27 +1380,27 @@ "testing", "xunit" ], - "time": "2016-06-16 06:01:15" + "time": "2017-04-03T02:22:27+00:00" }, { "name": "phpunit/phpunit-mock-objects", - "version": "3.2.3", + "version": "3.4.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "b13d0d9426ced06958bd32104653526a6c998a52" + "reference": "3ab72b65b39b491e0c011e2e09bb2206c2aa8e24" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/b13d0d9426ced06958bd32104653526a6c998a52", - "reference": "b13d0d9426ced06958bd32104653526a6c998a52", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/3ab72b65b39b491e0c011e2e09bb2206c2aa8e24", + "reference": "3ab72b65b39b491e0c011e2e09bb2206c2aa8e24", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", "php": "^5.6 || ^7.0", "phpunit/php-text-template": "^1.2", - "sebastian/exporter": "^1.2" + "sebastian/exporter": "^1.2 || ^2.0" }, "conflict": { "phpunit/phpunit": "<5.4.0" @@ -1413,27 +1439,27 @@ "mock", "xunit" ], - "time": "2016-06-12 07:37:26" + "time": "2016-12-08T20:27:08+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", - "version": "1.0.0", + "version": "1.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", - "reference": "c36f5e7cfce482fde5bf8d10d41a53591e0198fe" + "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/c36f5e7cfce482fde5bf8d10d41a53591e0198fe", - "reference": "c36f5e7cfce482fde5bf8d10d41a53591e0198fe", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", + "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", "shasum": "" }, "require": { - "php": ">=5.6" + "php": "^5.6 || ^7.0" }, "require-dev": { - "phpunit/phpunit": "~5" + "phpunit/phpunit": "^5.7 || ^6.0" }, "type": "library", "extra": { @@ -1458,26 +1484,26 @@ ], "description": "Looks up which function or method a line of code belongs to", "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", - "time": "2016-02-13 06:45:14" + "time": "2017-03-04T06:30:41+00:00" }, { "name": "sebastian/comparator", - "version": "1.2.0", + "version": "1.2.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "937efb279bd37a375bcadf584dec0726f84dbf22" + "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/937efb279bd37a375bcadf584dec0726f84dbf22", - "reference": "937efb279bd37a375bcadf584dec0726f84dbf22", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", + "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", "shasum": "" }, "require": { "php": ">=5.3.3", "sebastian/diff": "~1.2", - "sebastian/exporter": "~1.2" + "sebastian/exporter": "~1.2 || ~2.0" }, "require-dev": { "phpunit/phpunit": "~4.4" @@ -1522,7 +1548,7 @@ "compare", "equality" ], - "time": "2015-07-26 15:48:44" + "time": "2017-01-29T09:50:25+00:00" }, { "name": "sebastian/diff", @@ -1574,32 +1600,32 @@ "keywords": [ "diff" ], - "time": "2015-12-08 07:14:41" + "time": "2015-12-08T07:14:41+00:00" }, { "name": "sebastian/environment", - "version": "1.3.7", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "4e8f0da10ac5802913afc151413bc8c53b6c2716" + "reference": "5795ffe5dc5b02460c3e34222fee8cbe245d8fac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/4e8f0da10ac5802913afc151413bc8c53b6c2716", - "reference": "4e8f0da10ac5802913afc151413bc8c53b6c2716", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/5795ffe5dc5b02460c3e34222fee8cbe245d8fac", + "reference": "5795ffe5dc5b02460c3e34222fee8cbe245d8fac", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^5.6 || ^7.0" }, "require-dev": { - "phpunit/phpunit": "~4.4" + "phpunit/phpunit": "^5.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3.x-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { @@ -1624,25 +1650,25 @@ "environment", "hhvm" ], - "time": "2016-05-17 03:18:57" + "time": "2016-11-26T07:53:53+00:00" }, { "name": "sebastian/exporter", - "version": "1.2.2", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "42c4c2eec485ee3e159ec9884f95b431287edde4" + "reference": "ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/42c4c2eec485ee3e159ec9884f95b431287edde4", - "reference": "42c4c2eec485ee3e159ec9884f95b431287edde4", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4", + "reference": "ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4", "shasum": "" }, "require": { "php": ">=5.3.3", - "sebastian/recursion-context": "~1.0" + "sebastian/recursion-context": "~2.0" }, "require-dev": { "ext-mbstring": "*", @@ -1651,7 +1677,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3.x-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { @@ -1691,7 +1717,7 @@ "export", "exporter" ], - "time": "2016-06-17 09:04:28" + "time": "2016-11-19T08:54:04+00:00" }, { "name": "sebastian/global-state", @@ -1742,25 +1768,25 @@ "keywords": [ "global state" ], - "time": "2015-10-12 03:26:01" + "time": "2015-10-12T03:26:01+00:00" }, { "name": "sebastian/object-enumerator", - "version": "1.0.0", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "d4ca2fb70344987502567bc50081c03e6192fb26" + "reference": "1311872ac850040a79c3c058bea3e22d0f09cbb7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/d4ca2fb70344987502567bc50081c03e6192fb26", - "reference": "d4ca2fb70344987502567bc50081c03e6192fb26", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/1311872ac850040a79c3c058bea3e22d0f09cbb7", + "reference": "1311872ac850040a79c3c058bea3e22d0f09cbb7", "shasum": "" }, "require": { "php": ">=5.6", - "sebastian/recursion-context": "~1.0" + "sebastian/recursion-context": "~2.0" }, "require-dev": { "phpunit/phpunit": "~5" @@ -1768,7 +1794,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { @@ -1788,20 +1814,20 @@ ], "description": "Traverses array structures and object graphs to enumerate all referenced objects", "homepage": "https://github.com/sebastianbergmann/object-enumerator/", - "time": "2016-01-28 13:25:10" + "time": "2017-02-18T15:18:39+00:00" }, { "name": "sebastian/recursion-context", - "version": "1.0.2", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "913401df809e99e4f47b27cdd781f4a258d58791" + "reference": "2c3ba150cbec723aa057506e73a8d33bdb286c9a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/913401df809e99e4f47b27cdd781f4a258d58791", - "reference": "913401df809e99e4f47b27cdd781f4a258d58791", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/2c3ba150cbec723aa057506e73a8d33bdb286c9a", + "reference": "2c3ba150cbec723aa057506e73a8d33bdb286c9a", "shasum": "" }, "require": { @@ -1813,7 +1839,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { @@ -1841,7 +1867,7 @@ ], "description": "Provides functionality to recursively process PHP variables", "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2015-11-11 19:50:13" + "time": "2016-11-19T07:33:16+00:00" }, { "name": "sebastian/resource-operations", @@ -1883,20 +1909,20 @@ ], "description": "Provides a list of PHP built-in functions that operate on resources", "homepage": "https://www.github.com/sebastianbergmann/resource-operations", - "time": "2015-07-28 20:34:47" + "time": "2015-07-28T20:34:47+00:00" }, { "name": "sebastian/version", - "version": "2.0.0", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/version.git", - "reference": "c829badbd8fdf16a0bad8aa7fa7971c029f1b9c5" + "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c829badbd8fdf16a0bad8aa7fa7971c029f1b9c5", - "reference": "c829badbd8fdf16a0bad8aa7fa7971c029f1b9c5", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/99732be0ddb3361e16ad77b68ba41efc8e979019", + "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019", "shasum": "" }, "require": { @@ -1926,20 +1952,20 @@ ], "description": "Library that helps with managing the version number of Git-hosted PHP projects", "homepage": "https://github.com/sebastianbergmann/version", - "time": "2016-02-04 12:56:52" + "time": "2016-10-03T07:35:21+00:00" }, { "name": "squizlabs/php_codesniffer", - "version": "2.6.1", + "version": "2.8.1", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "fb72ed32f8418db5e7770be1653e62e0d6f5dd3d" + "reference": "d7cf0d894e8aa4c73712ee4a331cc1eaa37cdc7d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/fb72ed32f8418db5e7770be1653e62e0d6f5dd3d", - "reference": "fb72ed32f8418db5e7770be1653e62e0d6f5dd3d", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/d7cf0d894e8aa4c73712ee4a331cc1eaa37cdc7d", + "reference": "d7cf0d894e8aa4c73712ee4a331cc1eaa37cdc7d", "shasum": "" }, "require": { @@ -2004,29 +2030,35 @@ "phpcs", "standards" ], - "time": "2016-05-30 22:24:32" + "time": "2017-03-01T22:17:45+00:00" }, { "name": "symfony/yaml", - "version": "v3.1.2", + "version": "v3.2.7", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "2884c26ce4c1d61aebf423a8b912950fe7c764de" + "reference": "62b4cdb99d52cb1ff253c465eb1532a80cebb621" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/2884c26ce4c1d61aebf423a8b912950fe7c764de", - "reference": "2884c26ce4c1d61aebf423a8b912950fe7c764de", + "url": "https://api.github.com/repos/symfony/yaml/zipball/62b4cdb99d52cb1ff253c465eb1532a80cebb621", + "reference": "62b4cdb99d52cb1ff253c465eb1532a80cebb621", "shasum": "" }, "require": { "php": ">=5.5.9" }, + "require-dev": { + "symfony/console": "~2.8|~3.0" + }, + "suggest": { + "symfony/console": "For validating YAML files using the lint command" + }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.1-dev" + "dev-master": "3.2-dev" } }, "autoload": { @@ -2053,32 +2085,33 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2016-06-29 05:41:56" + "time": "2017-03-20T09:45:15+00:00" }, { "name": "webmozart/assert", - "version": "1.0.2", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "30eed06dd6bc88410a4ff7f77b6d22f3ce13dbde" + "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/30eed06dd6bc88410a4ff7f77b6d22f3ce13dbde", - "reference": "30eed06dd6bc88410a4ff7f77b6d22f3ce13dbde", + "url": "https://api.github.com/repos/webmozart/assert/zipball/2db61e59ff05fe5126d152bd0655c9ea113e550f", + "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f", "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.3-dev" } }, "autoload": { @@ -2102,7 +2135,7 @@ "check", "validate" ], - "time": "2015-08-24 13:29:44" + "time": "2016-11-23T20:04:58+00:00" } ], "aliases": [], diff --git a/examples/cache/Laravel.php b/examples/cache/Laravel.php new file mode 100644 index 0000000..a88bb1a --- /dev/null +++ b/examples/cache/Laravel.php @@ -0,0 +1,33 @@ +input('needle'); + + /** + * Caching search for that needle for 10 minutes + */ + $tmp = Cache::remember('users.player.' . (string)$needle, 10, function () use ($needle, $client) { + return $client->player($needle); + }); + + return view('search', compact($tmp)); + } +} diff --git a/examples/cache/phpFastCache.php b/examples/cache/phpFastCache.php new file mode 100644 index 0000000..08e59c3 --- /dev/null +++ b/examples/cache/phpFastCache.php @@ -0,0 +1,36 @@ + '/path/to/your/cache/folder', + ]); + +// In your class, function, you can call the Cache +$InstanceCache = CacheManager::getInstance('files'); + +$client = new APIClient(); + +/** + * Try to get $products from Caching First + * product_page is "identity keyword"; + */ +$key = "player_" . $player_id; +$CachedRequest = $InstanceCache->getItem($key); + +if (is_null($CachedRequest->get())) { + $request = $client->player($player_id); + + $CachedRequest->set($request)->expiresAfter(5);//in seconds, also accepts Datetime + $InstanceCache->save($CachedRequest); // Save the cache item just like you do with doctrine and entities +} + +var_dump($CachedRequest->get()); diff --git a/examples/example_bans.php b/examples/example_bans.php deleted file mode 100644 index 540fbf3..0000000 --- a/examples/example_bans.php +++ /dev/null @@ -1,18 +0,0 @@ -bans(50); - - -echo "

Ban reasons:

"; -foreach ($bans as $ban) -{ - printf('

Banned by: %s
', $ban->adminName); - printf('Reason: %s
', $ban->reason); - printf('At: %s
', $ban->created); - printf('Until: %s

', $ban->expires); -} - diff --git a/examples/example_game_time.php b/examples/example_game_time.php deleted file mode 100644 index 9491fae..0000000 --- a/examples/example_game_time.php +++ /dev/null @@ -1,13 +0,0 @@ -game_time(); //Use the class variable to access one of the class functions. - -echo "

Year-Month-Day Hours:Minutes

"; -echo "

Current Game time: " . $time['years'] . "-" . $time['months'] . "-" . $time['days'] . " " . $time['hours'] . ":" . $time['minutes'] . "

"; - -echo "
"; -var_dump($time); //Dumping all of the information so you can see what is available. diff --git a/examples/example_servers.php b/examples/example_servers.php deleted file mode 100644 index 26115ee..0000000 --- a/examples/example_servers.php +++ /dev/null @@ -1,21 +0,0 @@ -servers(); //Use the class variable to access one of the class functions. - -echo "

Servers:

"; -foreach ($servers['response'] as $v) -{ //Foreach to loop through all servers supplied by the API and print their statuses. - if ($v['online'] == TRUE) { - $online = "Online"; - } else { - $online = "Offline"; - } - echo "

" . $v['game'] . " " . $v['name'] . ":" . $online . "(" . $v['players'] . "/" . $v['maxplayers'] . ")" ."

"; -} - -echo "
"; -var_dump($servers); //Dumping all of the information so you can see what is available. diff --git a/examples/example_user.php b/examples/example_user.php deleted file mode 100644 index 4fede46..0000000 --- a/examples/example_user.php +++ /dev/null @@ -1,13 +0,0 @@ -player(1); //Use the class variable to access one of the class functions, loading the player with ID 1. Also works with SteamID64. - -echo "Player 1 is " . $thisplayer['response']['name'] . '
'; //Write the information about Player 1 to the document. -echo "(S)He is a " . $thisplayer['response']['groupName'] . '
'; - -echo "
"; -var_dump($thisplayer); //Dumping all of the information so you can see what is available. diff --git a/examples/example_version.php b/examples/example_version.php deleted file mode 100644 index db4d9e6..0000000 --- a/examples/example_version.php +++ /dev/null @@ -1,12 +0,0 @@ -version(); //Use the class variable to access one of the class functions. - -echo "

TruckersMP Version: " . $version['name'] . "

"; - -echo "
"; -var_dump($version); //Dumping all of the information so you can see what is available. diff --git a/readme.md b/readme.md index f31ac73..f65cbdb 100644 --- a/readme.md +++ b/readme.md @@ -2,41 +2,40 @@ [![Build Status](https://travis-ci.org/TruckersMP/API-Client.svg?branch=master)](https://travis-ci.org/TruckersMP/API-Client) -This is a PHP library created to simplify development using the [TruckersMP](http://truckersmp.com/) API. This client library provides functions to connect and gather data from each API endpoint, and returns the data as an array. +This is a PHP library created to simplify development using the [TruckersMP](http://truckersmp.com/) API. This client library provides functions to connect and gather data from each API endpoint, and returns the data as an object. + +> If you want to use API without library (or if you have advanced knowledge of PHP), check out [API documentation](https://stats.truckersmp.com/api). + +## Warning! + +Please use our service responsibly. API Consumers who require high rates of requests against our APIs should contact TruckersMP Staff with a rationale and contact email for high-rate usage. + ## Requirements -- PHP 5.6.0 or newer. +- PHP 5.6.0 or newer - Composer ## Installation This library can be installed using [Composer](http://getcomposer.org/). -Simple method: You can include this library in your `composer.json` requirements list by using the command `composer require truckersmp/api-client`. - -Slightly less simple method: You can also add `truckersmp/api-client` manually to the composer requirements list. +Two ways: +1. Execute command `composer require truckersmp/api-client` +2. Add `truckersmp/api-client` manually to the composer requirements list. -After doing either of the above, open a commandline or terminal in that directory and use the command `composer install`. +After doing either of the above, execute the command `composer install`. ## Usage -``` +> **Please note: this examples doesn't use caching. You should cache your requests in order to use API responsibly. Some examples can be found in `examples\cache` folder.** + +```php client = new APIClient($adapter); +$client = new APIClient(); // Get player data for player id 50 $player = $client->player(50); @@ -52,9 +51,33 @@ echo $player->groupName; ``` +## Methods + +`player()` - find player by TruckersMP ID or Steam ID + +`bans()` - view bans by TruckersMP ID + +`servers()` - servers list + +`gameTime()` - gameserver time (uses [Carbon](http://carbon.nesbot.com/docs/)) + +`version()`- TruckersMP version info + +## Configuration + +We use [Guzzle](https://github.com/guzzle/guzzle) for gathering data from API endpoint. If you want to change Guzzle [configuration](http://guzzlephp.org/), you can pass config array on Client initialization. + +```php +apiEndpoint = $apiEndpoint; - $this->version = $version; + public function __construct($config = [], $secure = true) + { $scheme = $secure ? 'https' : 'http'; + $url = $scheme . '://' . self::API_ENDPOINT . '/' . self::API_VERSION . '/'; - $this->url = $scheme . '://' . $this->apiEndpoint . '/' . $this->version . '/'; - - $this->adapter = $adapter; - + $this->request = new Request($url, $config); } /** - * Fetch player information - * @param integer $id - * @return Player + * Fetch player information. + * + * @param int $id + * + * @throws \Exception + * @throws \Http\Client\Exception + * + * @return \TruckersMP\Types\Player */ public function player($id) { - $message = new GuzzleMessageFactory(); - - $request = $message->createRequest('GET', $this->url . 'player/' . $id); - - $result = $this->adapter->sendRequest($request); + $result = $this->request->execute('player/' . $id); return new Player($result); } + /** + * @param $id + * + * @throws \Exception + * @throws \Http\Client\Exception + * + * @return \TruckersMP\Types\Bans + */ public function bans($id) { - $message = new GuzzleMessageFactory(); - - $request = $message->createRequest('GET', $this->url . 'bans/' . $id); + $result = $this->request->execute('bans/' . $id); - $result = $this->adapter->sendRequest($request); return new Bans($result); } + /** + * @throws \Exception + * @throws \Http\Client\Exception + * + * @return \TruckersMP\Types\Servers + */ public function servers() { - $message = new GuzzleMessageFactory(); - - $request = $message->createRequest('GET', $this->url . 'servers'); + $result = $this->request->execute('servers'); - $result = $this->adapter->sendRequest($request); return new Servers($result); } + /** + * @throws \Exception + * @throws \Http\Client\Exception + * + * @return \TruckersMP\Types\GameTime + */ public function gameTime() { - $message = new GuzzleMessageFactory(); - - $request = $message->createRequest('GET', $this->url . 'game_time'); - - $result = $this->adapter->sendRequest($request); + $result = $this->request->execute('game_time'); return new GameTime($result); } + /** + * @throws \Exception + * @throws \Http\Client\Exception + * + * @return \TruckersMP\Types\Version + */ public function version() { - $message = new GuzzleMessageFactory(); - - $request = $message->createRequest('GET', $this->url . 'version'); + $result = $this->request->execute('version'); - $result = $this->adapter->sendRequest($request); return new Version($result); } } diff --git a/src/API/Request.php b/src/API/Request.php new file mode 100644 index 0000000..d0737c4 --- /dev/null +++ b/src/API/Request.php @@ -0,0 +1,58 @@ +message = new GuzzleMessageFactory(); + + $this->apiEndpoint = $apiEndpoint; + $this->adapter = new GuzzleAdapter(new GuzzleClient($config)); + } + + /** + * @param string $uri URI of API method + * + * @return array + */ + public function execute($uri) + { + $request = $this->message->createRequest('GET', $this->apiEndpoint . $uri); + $result = $this->adapter->sendRequest($request); + + return json_decode((string)$result->getBody(), true, 512, JSON_BIGINT_AS_STRING); + } +} diff --git a/src/Exceptions/APIErrorException.php b/src/Exceptions/APIErrorException.php index acd204f..28749af 100644 --- a/src/Exceptions/APIErrorException.php +++ b/src/Exceptions/APIErrorException.php @@ -3,12 +3,11 @@ * Created by PhpStorm. * User: thor * Date: 24.06.16 - * Time: 14:06 + * Time: 14:06. */ namespace TruckersMP\Exceptions; class APIErrorException extends \Exception { - } diff --git a/src/Exceptions/PlayerNotFoundException.php b/src/Exceptions/PlayerNotFoundException.php index 6724acb..b545c22 100644 --- a/src/Exceptions/PlayerNotFoundException.php +++ b/src/Exceptions/PlayerNotFoundException.php @@ -3,12 +3,11 @@ * Created by PhpStorm. * User: thor * Date: 24.06.16 - * Time: 11:19 + * Time: 11:19. */ namespace TruckersMP\Exceptions; class PlayerNotFoundException extends \Exception { - } diff --git a/src/Types/Ban.php b/src/Types/Ban.php index fbdc4fa..30c23ad 100644 --- a/src/Types/Ban.php +++ b/src/Types/Ban.php @@ -1,57 +1,66 @@ expires = new Carbon($ban['expiration'], 'UTC'); $this->created = new Carbon($ban['timeAdded'], 'UTC'); - $this->active = $ban['active']; + $this->active = $ban['active']; - $this->reason = $ban['reason']; + $this->reason = $ban['reason']; $this->adminName = $ban['adminName']; - $this->adminID = $ban['adminID']; - + $this->adminID = $ban['adminID']; } } diff --git a/src/Types/Bans.php b/src/Types/Bans.php index 7eb2756..c64576f 100644 --- a/src/Types/Bans.php +++ b/src/Types/Bans.php @@ -1,6 +1,5 @@ position = 0; - $json = json_decode((string)$response->getBody(), true, 512, JSON_BIGINT_AS_STRING); - - if ($json['error'] && - ($json['descriptor'] == 'No player ID submitted' || - $json['descriptor'] == 'Invalid user ID')) { - throw new PlayerNotFoundException($json['descriptor']); + if ($response['error'] && + ($response['descriptor'] == 'No player ID submitted' || + $response['descriptor'] == 'Invalid user ID') + ) { + throw new PlayerNotFoundException($response['descriptor']); } - foreach ($json['response'] as $k => $ban) { + foreach ($response['response'] as $k => $ban) { $this->bans[$k] = new Ban($ban); } } @@ -48,11 +48,17 @@ public function rewind() $this->position = 0; } + /** + * @return mixed + */ public function current() { return $this->bans[$this->position]; } + /** + * @return int + */ public function key() { return $this->position; @@ -63,28 +69,52 @@ public function next() ++$this->position; } + /** + * @return bool + */ public function valid() { return isset($this->bans[$this->position]); } + /** + * @param mixed $offset + * @param mixed $value + * + * @return \Exception + */ public function offsetSet($offset, $value) { // TODO: custom class that gives a better description of the error return new \Exception('Can not change bans'); } + /** + * @param mixed $offset + * + * @return bool + */ public function offsetExists($offset) { return isset($this->bans[$offset]); } + /** + * @param mixed $offset + * + * @return \Exception + */ public function offsetUnset($offset) { // TODO: custom class that gives a better description of the error return new \Exception('Can not change bans'); } + /** + * @param mixed $offset + * + * @return mixed|null + */ public function offsetGet($offset) { return isset($this->bans[$offset]) ? $this->bans[$offset] : null; diff --git a/src/Types/GameTime.php b/src/Types/GameTime.php index 636ef6c..46a5c38 100644 --- a/src/Types/GameTime.php +++ b/src/Types/GameTime.php @@ -3,42 +3,44 @@ * Created by PhpStorm. * User: thor * Date: 12.07.16 - * Time: 09:55 + * Time: 09:55. */ namespace TruckersMP\Types; use Carbon\Carbon; -use Psr\Http\Message\ResponseInterface; class GameTime { - public $time; - public function __construct(ResponseInterface $response) + /** + * GameTime constructor. + * + * @param array $response + * + * @throws \Exception + */ + public function __construct(array $response) { - $json = json_decode((string)$response->getBody(), true, 512, JSON_BIGINT_AS_STRING); - - if ($json['error']) { + if ($response['error']) { // TODO: actually throw a usable error throw new \Exception('API Error'); } - $load['minutes'] = $json['game_time']; + $load['minutes'] = $response['game_time']; - $load['hours'] = $load['minutes'] / 60; + $load['hours'] = $load['minutes'] / 60; $load['minutes'] = $load['minutes'] % 60; - $load['days'] = $load['hours'] / 24; + $load['days'] = $load['hours'] / 24; $load['hours'] = $load['hours'] % 24; $load['months'] = $load['days'] / 30; - $load['days'] = $load['days'] % 30; + $load['days'] = $load['days'] % 30; - $load['years'] = intval($load['months'] / 12); + $load['years'] = intval($load['months'] / 12); $load['months'] = $load['months'] % 12; $this->time = Carbon::create($load['years'], $load['months'], $load['days'], $load['hours'], $load['minutes']); - } } diff --git a/src/Types/Player.php b/src/Types/Player.php index 0f82924..ac3e4cf 100644 --- a/src/Types/Player.php +++ b/src/Types/Player.php @@ -1,82 +1,87 @@ getBody(), true, 512, JSON_BIGINT_AS_STRING); - - if ($json['error']) { - throw new PlayerNotFoundException($json['response']); + if ($response['error']) { + throw new PlayerNotFoundException($response['response']); } - $this->id = $json['response']['id']; - $this->name = $json['response']['name']; - $this->avatar = $json['response']['avatar']; - $this->joinDate = $json['response']['joinDate']; - $this->steamID64 = $json['response']['steamID64']; - $this->groupID = $json['response']['groupID']; - $this->groupName = $json['response']['groupName']; - $this->inGameAdmin = $json['response']['permissions']['isGameAdmin']; + $this->id = $response['response']['id']; + $this->name = $response['response']['name']; + $this->avatar = $response['response']['avatar']; + $this->joinDate = $response['response']['joinDate']; + $this->steamID64 = $response['response']['steamID64']; + $this->groupID = $response['response']['groupID']; + $this->groupName = $response['response']['groupName']; + $this->inGameAdmin = $response['response']['permissions']['isGameAdmin']; } } diff --git a/src/Types/Server.php b/src/Types/Server.php index 4f6db5e..5a1a0b2 100644 --- a/src/Types/Server.php +++ b/src/Types/Server.php @@ -4,108 +4,124 @@ class Server { - /** - * Game server ID + * Game server ID. + * * @var int */ public $id; /** - * Game + * Game. + * * @var string */ public $game; /** - * IP or Hostname of server + * IP or Hostname of server. + * * @var string */ public $ip; /** - * Port + * Port. + * * @var int */ public $port; /** - * Game server name + * Game server name. + * * @var string */ public $name; /** - * Game server short name + * Game server short name. + * * @var string */ public $shortName; /** - * Online status + * Online status. + * * @var bool */ public $online; /** - * Current player count + * Current player count. + * * @var int */ public $players; /** - * Current queue count + * Current queue count. + * * @var int */ public $queue; /** - * Max player count + * Max player count. + * * @var int */ public $maxPlayers; /** - * Speed limiter + * Speed limiter. + * * @var bool */ public $speedLimiter; /** - * Collisions + * Collisions. + * * @var bool */ public $collisions; /** - * Will cars be available for all players + * Will cars be available for all players. + * * @var bool */ public $carsForPlayers; /** - * Will police cars be available for all players + * Will police cars be available for all players. + * * @var bool */ public $policeCarsForPlayers; /** - * "Away from keyboard" status + * "Away from keyboard" status. + * * @var bool */ public $afkEnabled; /** - * Sync delay (tick rate) + * Sync delay (tick rate). + * * @var bool */ public $syncDelay; /** * Server constructor. - * @param $server + * + * @param array $server */ - public function __construct($server) + public function __construct(array $server) { $this->id = intval($server['id']); $this->game = $server['game']; diff --git a/src/Types/Servers.php b/src/Types/Servers.php index 6f22656..00c8c90 100644 --- a/src/Types/Servers.php +++ b/src/Types/Servers.php @@ -7,35 +7,36 @@ class Servers implements \Iterator, \ArrayAccess { - /** - * Iterator position - * @var int + * Array of servers. + * + * @var array */ - private $position = 0; + public $servers; /** - * Array of servers - * @var array + * Iterator position. + * + * @var int */ - public $servers; + private $position = 0; /** * Servers constructor. - * @param ResponseInterface $response + * + * @param array $response + * * @throws APIErrorException */ - public function __construct(ResponseInterface $response) + public function __construct(array $response) { $this->position = 0; - $json = json_decode((string)$response->getBody(), true, 512, JSON_BIGINT_AS_STRING); - - if ($json['error'] == "true" && $json['descriptor'] == 'Unable to fetch servers') { - throw new APIErrorException($json['descriptor']); + if ($response['error'] == 'true' && $response['descriptor'] == 'Unable to fetch servers') { + throw new APIErrorException($response['descriptor']); } - foreach ($json['response'] as $k => $server) { + foreach ($response['response'] as $k => $server) { $this->servers[$k] = new Server($server); } } diff --git a/src/Types/Version.php b/src/Types/Version.php index 4a708d4..9765a2b 100644 --- a/src/Types/Version.php +++ b/src/Types/Version.php @@ -3,13 +3,12 @@ * Created by PhpStorm. * User: thor * Date: 27.06.16 - * Time: 09:46 + * Time: 09:46. */ namespace TruckersMP\Types; use Carbon\Carbon; -use Psr\Http\Message\ResponseInterface; class Version { @@ -21,29 +20,30 @@ class Version public $support; - public function __construct(ResponseInterface $response) + /** + * Version constructor. + * + * @param array $response + */ + public function __construct(array $response) { - $json = json_decode((string)$response->getBody(), true, 512, JSON_BIGINT_AS_STRING); - - - $this->version = new \stdClass(); - $this->version->human = $json['name']; - $this->version->stage = $json['stage']; - $this->version->nummeric = $json['numeric']; - - $this->checksum = new \stdClass(); - $this->checksum->atsmp = new \stdClass(); - $this->checksum->atsmp->dll = $json['atsmp_checksum']['dll']; - $this->checksum->atsmp->adb = $json['atsmp_checksum']['adb']; - $this->checksum->ets2mp = new \stdClass(); - $this->checksum->ets2mp->dll = $json['atsmp_checksum']['dll']; - $this->checksum->ets2mp->adb = $json['atsmp_checksum']['adb']; - - $this->released = new Carbon($json['time'], 'UTC'); - - $this->support = new \stdClass(); - $this->support->ets2 = $json['supported_game_version']; - $this->support->ats = $json['supported_ats_game_version']; - + $this->version = new \stdClass(); + $this->version->human = $response['name']; + $this->version->stage = $response['stage']; + $this->version->nummeric = $response['numeric']; + + $this->checksum = new \stdClass(); + $this->checksum->atsmp = new \stdClass(); + $this->checksum->atsmp->dll = $response['atsmp_checksum']['dll']; + $this->checksum->atsmp->adb = $response['atsmp_checksum']['adb']; + $this->checksum->ets2mp = new \stdClass(); + $this->checksum->ets2mp->dll = $response['atsmp_checksum']['dll']; + $this->checksum->ets2mp->adb = $response['atsmp_checksum']['adb']; + + $this->released = new Carbon($response['time'], 'UTC'); + + $this->support = new \stdClass(); + $this->support->ets2 = $response['supported_game_version']; + $this->support->ats = $response['supported_ats_game_version']; } }