diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..6537ca4 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false + +[*.{yml,yaml}] +indent_size = 2 diff --git a/.gitignore b/.gitignore index 34a600c..4af8a0e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,13 @@ -### Composer ### +# Composer composer.phar /vendor/ + +# PHPStorm /.idea/ -/Tests/cache/ +# Unit Tests +/tests/cache/ +.phpunit.result.cache +# Mac OS +.DS_Store diff --git a/.travis.yml b/.travis.yml index 4b61daa..8905453 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,10 +7,9 @@ cache: - $HOME/.composer/cache php: - - 7.1 - 7.2 - 7.3 - - hhvm + - 7.4 before_install: - composer self-update @@ -21,4 +20,6 @@ install: script: - vendor/bin/phpunit - vendor/bin/phpcs src --standard=PSR2 - - vendor/bin/phpcs Tests --standard=PSR2 + - vendor/bin/phpcs tests/Unit --standard=PSR2 + + diff --git a/Tests/ClientTest.php b/Tests/ClientTest.php deleted file mode 100644 index 41cdcbe..0000000 --- a/Tests/ClientTest.php +++ /dev/null @@ -1,98 +0,0 @@ -client = new APIClient(); - } - - /** - * @throws \Exception - * @throws \Http\Client\Exception - */ - public function testPlayer() - { - $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); - - $this->assertEquals($bans[0]->expires, '2016-06-19 13:00:00'); - $this->assertEquals($bans[0]->created, '2016-06-19 10:08:26'); - $this->assertEquals($bans[0]->reason, 'Test ban'); - - $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(); - - $this->assertNotEmpty($version->version->human); - $this->assertNotEmpty($version->version->stage); - $this->assertNotEmpty($version->version->nummeric); - - $this->assertNotEmpty($version->checksum->atsmp->dll); - $this->assertNotEmpty($version->checksum->atsmp->adb); - $this->assertNotEmpty($version->checksum->ets2mp->dll); - $this->assertNotEmpty($version->checksum->ets2mp->adb); - - $this->assertInstanceOf(Carbon::class, $version->released); - - $this->assertNotEmpty($version->support->ets2); - $this->assertNotEmpty($version->support->ats); - } - - public function testGameTime() - { - $time = $this->client->gameTime(); - - $this->assertNotEmpty($time); - } -} diff --git a/composer.json b/composer.json index 236f4fe..26d50b3 100644 --- a/composer.json +++ b/composer.json @@ -1,58 +1,71 @@ { - "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": "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" + }, + { + "name": "CJMAXiK", + "email": "me@cjmaxik.ru", + "homepage": "https://cjmaxik.ru", + "role": "IGA/Dev" + }, + { + "name": "Alex Blackham (B3none)", + "email": "ablackham2000@gmail.com", + "homepage": "https://github.com/b3none", + "role": "Dev" + }, + { + "name": "Ben Sherred (Ratcho)", + "email": "me@ratcho.dev", + "homepage": "https://github.com/bensherred", + "role": "Contributor" + } + ], + "require": { + "php": "^7.2", + "nesbot/carbon": "^2.16", + "ext-json": "*", + "phpfastcache/phpfastcache": "^7.1", + "php-http/message": "^1.8", + "guzzlehttp/psr7": "^1.6" }, - { - "name": "Thor Erik (Tuxy Fluffyclaws) Lie", - "email": "tuxy@truckersmp.com", - "homepage": "https://truckersmp.com/", - "role": "Dev" + "require-dev": { + "phpunit/phpunit": "^7.0", + "squizlabs/php_codesniffer": "^2.6", + "php-http/guzzle6-adapter": "^1.0" }, - { - "name": "CJMAXiK", - "email": "me@cjmaxik.ru", - "homepage": "https://cjmaxik.ru", - "role": "IGA/Dev" - } - ], - "require": { - "php": "^7.1", - "nesbot/carbon": "^1.21", - "php-http/message": "^1.2", - "guzzlehttp/psr7": "^1.3", - "ext-json": "*" - }, - "require-dev": { - "phpunit/phpunit": "^5.3", - "squizlabs/php_codesniffer": "^2.6", - "php-http/guzzle6-adapter": "^1.0" - }, - "autoload": { - "psr-4": { - "TruckersMP\\": "src/" + "autoload": { + "psr-4": { + "TruckersMP\\APIClient\\": "src/" + }, + "classmap": [ + "src/" + ] + }, + "autoload-dev": { + "psr-4": { + "Tests\\": "tests/" + } }, - "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/Unit --standard=PSR2" + ] } - }, - "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 6875e2b..b32d893 100644 --- a/composer.lock +++ b/composer.lock @@ -1,35 +1,38 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b1dd8f3b08c2fbe389ccc6ed1f4f8f96", + "content-hash": "562b22b6456a4c6eb412a36ca893f778", "packages": [ { "name": "clue/stream-filter", - "version": "v1.3.0", + "version": "v1.4.1", "source": { "type": "git", "url": "https://github.com/clue/php-stream-filter.git", - "reference": "e3bf9415da163d9ad6701dccb407ed501ae69785" + "reference": "5a58cc30a8bd6a4eb8f856adf61dd3e013f53f71" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/clue/php-stream-filter/zipball/e3bf9415da163d9ad6701dccb407ed501ae69785", - "reference": "e3bf9415da163d9ad6701dccb407ed501ae69785", + "url": "https://api.github.com/repos/clue/php-stream-filter/zipball/5a58cc30a8bd6a4eb8f856adf61dd3e013f53f71", + "reference": "5a58cc30a8bd6a4eb8f856adf61dd3e013f53f71", "shasum": "" }, "require": { "php": ">=5.3" }, + "require-dev": { + "phpunit/phpunit": "^5.0 || ^4.8" + }, "type": "library", "autoload": { "psr-4": { "Clue\\StreamFilter\\": "src/" }, "files": [ - "src/functions.php" + "src/functions_include.php" ] }, "notification-url": "https://packagist.org/downloads/", @@ -53,36 +56,41 @@ "stream_filter_append", "stream_filter_register" ], - "time": "2015-11-08T23:41:30+00:00" + "time": "2019-04-09T12:31:48+00:00" }, { "name": "guzzlehttp/psr7", - "version": "1.4.2", + "version": "1.6.1", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c" + "reference": "239400de7a173fe9901b9ac7c06497751f00727a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/f5b8a8512e2b58b0071a7280e39f14f72e05d87c", - "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/239400de7a173fe9901b9ac7c06497751f00727a", + "reference": "239400de7a173fe9901b9ac7c06497751f00727a", "shasum": "" }, "require": { "php": ">=5.4.0", - "psr/http-message": "~1.0" + "psr/http-message": "~1.0", + "ralouphie/getallheaders": "^2.0.5 || ^3.0.0" }, "provide": { "psr/http-message-implementation": "1.0" }, "require-dev": { - "phpunit/phpunit": "~4.0" + "ext-zlib": "*", + "phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.8" + }, + "suggest": { + "zendframework/zend-httphandlerrunner": "Emit PSR-7 responses" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4-dev" + "dev-master": "1.6-dev" } }, "autoload": { @@ -112,40 +120,54 @@ "keywords": [ "http", "message", + "psr-7", "request", "response", "stream", "uri", "url" ], - "time": "2017-03-20T17:10:46+00:00" + "time": "2019-07-01T23:21:34+00:00" }, { "name": "nesbot/carbon", - "version": "1.22.1", + "version": "2.27.0", "source": { "type": "git", "url": "https://github.com/briannesbitt/Carbon.git", - "reference": "7cdf42c0b1cc763ab7e4c33c47a24e27c66bfccc" + "reference": "13b8485a8690f103bf19cba64879c218b102b726" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/7cdf42c0b1cc763ab7e4c33c47a24e27c66bfccc", - "reference": "7cdf42c0b1cc763ab7e4c33c47a24e27c66bfccc", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/13b8485a8690f103bf19cba64879c218b102b726", + "reference": "13b8485a8690f103bf19cba64879c218b102b726", "shasum": "" }, "require": { - "php": ">=5.3.0", - "symfony/translation": "~2.6 || ~3.0" + "ext-json": "*", + "php": "^7.1.8 || ^8.0", + "symfony/translation": "^3.4 || ^4.0 || ^5.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "~2", - "phpunit/phpunit": "~4.0 || ~5.0" + "friendsofphp/php-cs-fixer": "^2.14 || ^3.0", + "kylekatarnls/multi-tester": "^1.1", + "phpmd/phpmd": "dev-php-7.1-compatibility", + "phpstan/phpstan": "^0.11", + "phpunit/phpunit": "^7.5 || ^8.0", + "squizlabs/php_codesniffer": "^3.4" }, + "bin": [ + "bin/carbon" + ], "type": "library", "extra": { "branch-alias": { - "dev-master": "1.23-dev" + "dev-master": "2.x-dev" + }, + "laravel": { + "providers": [ + "Carbon\\Laravel\\ServiceProvider" + ] } }, "autoload": { @@ -162,37 +184,44 @@ "name": "Brian Nesbitt", "email": "brian@nesbot.com", "homepage": "http://nesbot.com" + }, + { + "name": "kylekatarnls", + "homepage": "http://github.com/kylekatarnls" } ], - "description": "A simple API extension for DateTime.", + "description": "An API extension for DateTime that supports 281 different languages.", "homepage": "http://carbon.nesbot.com", "keywords": [ "date", "datetime", "time" ], - "time": "2017-01-16T07:55:07+00:00" + "time": "2019-11-20T06:59:06+00:00" }, { "name": "php-http/message", - "version": "1.5.0", + "version": "1.8.0", "source": { "type": "git", "url": "https://github.com/php-http/message.git", - "reference": "13df8c48f40ca7925303aa336f19be4b80984f01" + "reference": "ce8f43ac1e294b54aabf5808515c3554a19c1e1c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-http/message/zipball/13df8c48f40ca7925303aa336f19be4b80984f01", - "reference": "13df8c48f40ca7925303aa336f19be4b80984f01", + "url": "https://api.github.com/repos/php-http/message/zipball/ce8f43ac1e294b54aabf5808515c3554a19c1e1c", + "reference": "ce8f43ac1e294b54aabf5808515c3554a19c1e1c", "shasum": "" }, "require": { - "clue/stream-filter": "^1.3", - "php": ">=5.4", + "clue/stream-filter": "^1.4", + "php": "^7.1", "php-http/message-factory": "^1.0.2", "psr/http-message": "^1.0" }, + "provide": { + "php-http/message-factory-implementation": "1.0" + }, "require-dev": { "akeneo/phpspec-skip-example-extension": "^1.0", "coduo/phpspec-data-provider-extension": "^1.0", @@ -212,7 +241,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.6-dev" + "dev-master": "1.8-dev" } }, "autoload": { @@ -240,7 +269,7 @@ "message", "psr-7" ], - "time": "2017-02-14T08:58:37+00:00" + "time": "2019-08-05T06:55:08+00:00" }, { "name": "php-http/message-factory", @@ -292,6 +321,152 @@ ], "time": "2015-12-19T14:08:53+00:00" }, + { + "name": "phpfastcache/phpfastcache", + "version": "7.1.0", + "source": { + "type": "git", + "url": "https://github.com/PHPSocialNetwork/phpfastcache.git", + "reference": "11c7b17a824925c2b99dce10df15ba67cbef132a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPSocialNetwork/phpfastcache/zipball/11c7b17a824925c2b99dce10df15ba67cbef132a", + "reference": "11c7b17a824925c2b99dce10df15ba67cbef132a", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-mbstring": "*", + "php": ">=7.0", + "psr/cache": "~1.0.0", + "psr/simple-cache": "~1.0.0" + }, + "conflict": { + "basho/riak": "*", + "doctrine/couchdb": "*" + }, + "suggest": { + "ext-apc": "*", + "ext-couchbase": "*", + "ext-intl": "*", + "ext-leveldb": "*", + "ext-memcache": "*", + "ext-memcached": "*", + "ext-redis": "*", + "ext-sqlite": "*", + "ext-wincache": "*", + "ext-xcache": "*", + "mongodb/mongodb": "^1.1", + "phpfastcache/couchdb": "~1.0.0", + "phpfastcache/phpssdb": "~1.0.0", + "phpfastcache/riak-client": "~1.4.4", + "predis/predis": "~1.1.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Phpfastcache\\": "lib/Phpfastcache/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Georges.L", + "email": "contact@geolim4.com", + "homepage": "https://github.com/Geolim4", + "role": "Actual Project Manager/Developer" + }, + { + "name": "Khoa Bui", + "email": "khoaofgod@gmail.com", + "homepage": "https://www.phpfastcache.com", + "role": "Former Project Developer/Original Creator" + } + ], + "description": "PHP Abstract Cache Class - Reduce your database call using cache system. PhpFastCache handles a lot of drivers such as Apc(u), Cassandra, CouchBase, Couchdb, Mongodb, Files, (P)redis, Leveldb, Memcache(d), Ssdb, Sqlite, Wincache, Xcache, Zend Data Cache.", + "homepage": "https://www.phpfastcache.com", + "keywords": [ + "LevelDb", + "abstract", + "apc", + "apcu", + "cache", + "cache class", + "caching", + "cassandra", + "cookie", + "couchbase", + "couchdb", + "files cache", + "memcache", + "memcached", + "mongodb", + "mysql cache", + "pdo cache", + "php cache", + "predis", + "redis", + "ssdb", + "wincache", + "xcache", + "zend", + "zend data cache", + "zend disk cache", + "zend memory cache", + "zend server" + ], + "time": "2019-09-15T15:11:18+00:00" + }, + { + "name": "psr/cache", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/cache.git", + "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8", + "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Cache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for caching libraries", + "keywords": [ + "cache", + "psr", + "psr-6" + ], + "time": "2016-08-06T20:24:11+00:00" + }, { "name": "psr/http-message", "version": "1.0.1", @@ -342,18 +517,106 @@ ], "time": "2016-08-06T14:39:51+00:00" }, + { + "name": "psr/simple-cache", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/simple-cache.git", + "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", + "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\SimpleCache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interfaces for simple caching", + "keywords": [ + "cache", + "caching", + "psr", + "psr-16", + "simple-cache" + ], + "time": "2017-10-23T01:57:42+00:00" + }, + { + "name": "ralouphie/getallheaders", + "version": "3.0.3", + "source": { + "type": "git", + "url": "https://github.com/ralouphie/getallheaders.git", + "reference": "120b605dfeb996808c31b6477290a714d356e822" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", + "reference": "120b605dfeb996808c31b6477290a714d356e822", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.1", + "phpunit/phpunit": "^5 || ^6.5" + }, + "type": "library", + "autoload": { + "files": [ + "src/getallheaders.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ralph Khattar", + "email": "ralph.khattar@gmail.com" + } + ], + "description": "A polyfill for getallheaders.", + "time": "2019-03-08T08:55:37+00:00" + }, { "name": "symfony/polyfill-mbstring", - "version": "v1.3.0", + "version": "v1.13.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "e79d363049d1c2128f133a2667e4f4190904f7f4" + "reference": "7b4aab9743c30be783b73de055d24a39cf4b954f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/e79d363049d1c2128f133a2667e4f4190904f7f4", - "reference": "e79d363049d1c2128f133a2667e4f4190904f7f4", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/7b4aab9743c30be783b73de055d24a39cf4b954f", + "reference": "7b4aab9743c30be783b73de055d24a39cf4b954f", "shasum": "" }, "require": { @@ -365,7 +628,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3-dev" + "dev-master": "1.13-dev" } }, "autoload": { @@ -399,44 +662,57 @@ "portable", "shim" ], - "time": "2016-11-14T01:06:16+00:00" + "time": "2019-11-27T14:18:11+00:00" }, { "name": "symfony/translation", - "version": "v3.2.7", + "version": "v5.0.1", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "c740eee70783d2af4d3d6b70d5146f209e6b4d13" + "reference": "e86df1b0f1672362ecf96023faf2c42241c41330" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/c740eee70783d2af4d3d6b70d5146f209e6b4d13", - "reference": "c740eee70783d2af4d3d6b70d5146f209e6b4d13", + "url": "https://api.github.com/repos/symfony/translation/zipball/e86df1b0f1672362ecf96023faf2c42241c41330", + "reference": "e86df1b0f1672362ecf96023faf2c42241c41330", "shasum": "" }, "require": { - "php": ">=5.5.9", - "symfony/polyfill-mbstring": "~1.0" + "php": "^7.2.5", + "symfony/polyfill-mbstring": "~1.0", + "symfony/translation-contracts": "^2" }, "conflict": { - "symfony/config": "<2.8" + "symfony/config": "<4.4", + "symfony/dependency-injection": "<5.0", + "symfony/http-kernel": "<5.0", + "symfony/twig-bundle": "<5.0", + "symfony/yaml": "<4.4" + }, + "provide": { + "symfony/translation-implementation": "2.0" }, "require-dev": { "psr/log": "~1.0", - "symfony/config": "~2.8|~3.0", - "symfony/intl": "^2.8.18|^3.2.5", - "symfony/yaml": "~2.8|~3.0" + "symfony/config": "^4.4|^5.0", + "symfony/console": "^4.4|^5.0", + "symfony/dependency-injection": "^5.0", + "symfony/finder": "^4.4|^5.0", + "symfony/http-kernel": "^5.0", + "symfony/intl": "^4.4|^5.0", + "symfony/service-contracts": "^1.1.2|^2", + "symfony/yaml": "^4.4|^5.0" }, "suggest": { - "psr/log": "To use logging capability in translator", + "psr/log-implementation": "To use logging capability in translator", "symfony/config": "", "symfony/yaml": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.2-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -463,38 +739,97 @@ ], "description": "Symfony Translation Component", "homepage": "https://symfony.com", - "time": "2017-03-21T21:44:32+00:00" + "time": "2019-11-18T17:27:11+00:00" + }, + { + "name": "symfony/translation-contracts", + "version": "v2.0.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/translation-contracts.git", + "reference": "8cc682ac458d75557203b2f2f14b0b92e1c744ed" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/8cc682ac458d75557203b2f2f14b0b92e1c744ed", + "reference": "8cc682ac458d75557203b2f2f14b0b92e1c744ed", + "shasum": "" + }, + "require": { + "php": "^7.2.5" + }, + "suggest": { + "symfony/translation-implementation": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\Translation\\": "" + } + }, + "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": "Generic abstractions related to translation", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "time": "2019-11-18T17:27:11+00:00" } ], "packages-dev": [ { "name": "doctrine/instantiator", - "version": "1.0.5", + "version": "1.3.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" + "reference": "ae466f726242e637cebdd526a7d991b9433bacf1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/ae466f726242e637cebdd526a7d991b9433bacf1", + "reference": "ae466f726242e637cebdd526a7d991b9433bacf1", "shasum": "" }, "require": { - "php": ">=5.3,<8.0-DEV" + "php": "^7.1" }, "require-dev": { - "athletic/athletic": "~0.1.8", + "doctrine/coding-standard": "^6.0", "ext-pdo": "*", "ext-phar": "*", - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "~2.0" + "phpbench/phpbench": "^0.13", + "phpstan/phpstan-phpunit": "^0.11", + "phpstan/phpstan-shim": "^0.11", + "phpunit/phpunit": "^7.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.2.x-dev" } }, "autoload": { @@ -514,50 +849,54 @@ } ], "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://github.com/doctrine/instantiator", + "homepage": "https://www.doctrine-project.org/projects/instantiator.html", "keywords": [ "constructor", "instantiate" ], - "time": "2015-06-14T21:17:01+00:00" + "time": "2019-10-21T16:45:58+00:00" }, { "name": "guzzlehttp/guzzle", - "version": "6.2.3", + "version": "6.4.1", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "8d6c6cc55186db87b7dc5009827429ba4e9dc006" + "reference": "0895c932405407fd3a7368b6910c09a24d26db11" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/8d6c6cc55186db87b7dc5009827429ba4e9dc006", - "reference": "8d6c6cc55186db87b7dc5009827429ba4e9dc006", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/0895c932405407fd3a7368b6910c09a24d26db11", + "reference": "0895c932405407fd3a7368b6910c09a24d26db11", "shasum": "" }, "require": { + "ext-json": "*", "guzzlehttp/promises": "^1.0", - "guzzlehttp/psr7": "^1.4", + "guzzlehttp/psr7": "^1.6.1", "php": ">=5.5" }, "require-dev": { "ext-curl": "*", - "phpunit/phpunit": "^4.0", - "psr/log": "^1.0" + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0", + "psr/log": "^1.1" + }, + "suggest": { + "psr/log": "Required for using the Log middleware" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "6.2-dev" + "dev-master": "6.3-dev" } }, "autoload": { - "files": [ - "src/functions_include.php" - ], "psr-4": { "GuzzleHttp\\": "src/" - } + }, + "files": [ + "src/functions_include.php" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -581,7 +920,7 @@ "rest", "web service" ], - "time": "2017-02-28T22:50:30+00:00" + "time": "2019-10-23T15:58:00+00:00" }, { "name": "guzzlehttp/promises", @@ -636,37 +975,43 @@ }, { "name": "myclabs/deep-copy", - "version": "1.6.0", + "version": "1.9.3", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "5a5a9fc8025a08d8919be87d6884d5a92520cefe" + "reference": "007c053ae6f31bba39dfa19a7726f56e9763bbea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/5a5a9fc8025a08d8919be87d6884d5a92520cefe", - "reference": "5a5a9fc8025a08d8919be87d6884d5a92520cefe", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/007c053ae6f31bba39dfa19a7726f56e9763bbea", + "reference": "007c053ae6f31bba39dfa19a7726f56e9763bbea", "shasum": "" }, "require": { - "php": ">=5.4.0" + "php": "^7.1" + }, + "replace": { + "myclabs/deep-copy": "self.version" }, "require-dev": { - "doctrine/collections": "1.*", - "phpunit/phpunit": "~4.1" + "doctrine/collections": "^1.0", + "doctrine/common": "^2.6", + "phpunit/phpunit": "^7.1" }, "type": "library", "autoload": { "psr-4": { "DeepCopy\\": "src/DeepCopy/" - } + }, + "files": [ + "src/DeepCopy/deep_copy.php" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "description": "Create deep copies (clones) of your objects", - "homepage": "https://github.com/myclabs/DeepCopy", "keywords": [ "clone", "copy", @@ -674,7 +1019,109 @@ "object", "object graph" ], - "time": "2017-01-26T22:05:40+00:00" + "time": "2019-08-09T12:45:53+00:00" + }, + { + "name": "phar-io/manifest", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/phar-io/manifest.git", + "reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/7761fcacf03b4d4f16e7ccb606d4879ca431fcf4", + "reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-phar": "*", + "phar-io/version": "^2.0", + "php": "^5.6 || ^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", + "time": "2018-07-08T19:23:20+00:00" + }, + { + "name": "phar-io/version", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/phar-io/version.git", + "reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/version/zipball/45a2ec53a73c70ce41d55cedef9063630abaf1b6", + "reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Library for handling version information and constraints", + "time": "2018-07-08T19:19:57+00:00" }, { "name": "php-http/guzzle6-adapter", @@ -844,35 +1291,33 @@ }, { "name": "phpdocumentor/reflection-common", - "version": "1.0", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c" + "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/144c307535e82c8fdcaacbcfc1d6d8eeb896687c", - "reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/63a995caa1ca9e5590304cd845c15ad6d482a62a", + "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a", "shasum": "" }, "require": { - "php": ">=5.5" + "php": ">=7.1" }, "require-dev": { - "phpunit/phpunit": "^4.6" + "phpunit/phpunit": "~6" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "2.x-dev" } }, "autoload": { "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src" - ] + "phpDocumentor\\Reflection\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -894,33 +1339,39 @@ "reflection", "static analysis" ], - "time": "2015-12-27T11:43:31+00:00" + "time": "2018-08-07T13:53:10+00:00" }, { "name": "phpdocumentor/reflection-docblock", - "version": "3.1.1", + "version": "4.3.2", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e" + "reference": "b83ff7cfcfee7827e1e78b637a5904fe6a96698e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/8331b5efe816ae05461b7ca1e721c01b46bafb3e", - "reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/b83ff7cfcfee7827e1e78b637a5904fe6a96698e", + "reference": "b83ff7cfcfee7827e1e78b637a5904fe6a96698e", "shasum": "" }, "require": { - "php": ">=5.5", - "phpdocumentor/reflection-common": "^1.0@dev", - "phpdocumentor/type-resolver": "^0.2.0", + "php": "^7.0", + "phpdocumentor/reflection-common": "^1.0.0 || ^2.0.0", + "phpdocumentor/type-resolver": "~0.4 || ^1.0.0", "webmozart/assert": "^1.0" }, "require-dev": { - "mockery/mockery": "^0.9.4", - "phpunit/phpunit": "^4.4" + "doctrine/instantiator": "^1.0.5", + "mockery/mockery": "^1.0", + "phpunit/phpunit": "^6.4" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.x-dev" + } + }, "autoload": { "psr-4": { "phpDocumentor\\Reflection\\": [ @@ -939,41 +1390,40 @@ } ], "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-09-30T07:12:33+00:00" + "time": "2019-09-12T14:27:41+00:00" }, { "name": "phpdocumentor/type-resolver", - "version": "0.2.1", + "version": "1.0.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb" + "reference": "2e32a6d48972b2c1976ed5d8967145b6cec4a4a9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb", - "reference": "e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/2e32a6d48972b2c1976ed5d8967145b6cec4a4a9", + "reference": "2e32a6d48972b2c1976ed5d8967145b6cec4a4a9", "shasum": "" }, "require": { - "php": ">=5.5", - "phpdocumentor/reflection-common": "^1.0" + "php": "^7.1", + "phpdocumentor/reflection-common": "^2.0" }, "require-dev": { - "mockery/mockery": "^0.9.4", - "phpunit/phpunit": "^5.2||^4.8.24" + "ext-tokenizer": "^7.1", + "mockery/mockery": "~1", + "phpunit/phpunit": "^7.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "1.x-dev" } }, "autoload": { "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src/" - ] + "phpDocumentor\\Reflection\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -986,42 +1436,43 @@ "email": "me@mikevanriel.com" } ], - "time": "2016-11-25T06:54:22+00:00" + "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", + "time": "2019-08-22T18:11:29+00:00" }, { "name": "phpspec/prophecy", - "version": "v1.7.0", + "version": "1.9.0", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "93d39f1f7f9326d746203c7c056f300f7f126073" + "reference": "f6811d96d97bdf400077a0cc100ae56aa32b9203" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/93d39f1f7f9326d746203c7c056f300f7f126073", - "reference": "93d39f1f7f9326d746203c7c056f300f7f126073", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/f6811d96d97bdf400077a0cc100ae56aa32b9203", + "reference": "f6811d96d97bdf400077a0cc100ae56aa32b9203", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", "php": "^5.3|^7.0", - "phpdocumentor/reflection-docblock": "^2.0|^3.0.2", - "sebastian/comparator": "^1.1|^2.0", + "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0|^5.0", + "sebastian/comparator": "^1.1|^2.0|^3.0", "sebastian/recursion-context": "^1.0|^2.0|^3.0" }, "require-dev": { "phpspec/phpspec": "^2.5|^3.2", - "phpunit/phpunit": "^4.8 || ^5.6.5" + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.6.x-dev" + "dev-master": "1.8.x-dev" } }, "autoload": { - "psr-0": { - "Prophecy\\": "src/" + "psr-4": { + "Prophecy\\": "src/Prophecy" } }, "notification-url": "https://packagist.org/downloads/", @@ -1049,44 +1500,44 @@ "spy", "stub" ], - "time": "2017-03-02T20:05:34+00:00" + "time": "2019-10-03T11:07:50+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "4.0.8", + "version": "6.1.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "ef7b2f56815df854e66ceaee8ebe9393ae36a40d" + "reference": "807e6013b00af69b6c5d9ceb4282d0393dbb9d8d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ef7b2f56815df854e66ceaee8ebe9393ae36a40d", - "reference": "ef7b2f56815df854e66ceaee8ebe9393ae36a40d", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/807e6013b00af69b6c5d9ceb4282d0393dbb9d8d", + "reference": "807e6013b00af69b6c5d9ceb4282d0393dbb9d8d", "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 || ^2.0", - "sebastian/code-unit-reverse-lookup": "^1.0", - "sebastian/environment": "^1.3.2 || ^2.0", - "sebastian/version": "^1.0 || ^2.0" + "php": "^7.1", + "phpunit/php-file-iterator": "^2.0", + "phpunit/php-text-template": "^1.2.1", + "phpunit/php-token-stream": "^3.0", + "sebastian/code-unit-reverse-lookup": "^1.0.1", + "sebastian/environment": "^3.1 || ^4.0", + "sebastian/version": "^2.0.1", + "theseer/tokenizer": "^1.1" }, "require-dev": { - "ext-xdebug": "^2.1.4", - "phpunit/phpunit": "^5.7" + "phpunit/phpunit": "^7.0" }, "suggest": { - "ext-xdebug": "^2.5.1" + "ext-xdebug": "^2.6.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0.x-dev" + "dev-master": "6.1-dev" } }, "autoload": { @@ -1101,7 +1552,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -1112,29 +1563,32 @@ "testing", "xunit" ], - "time": "2017-04-02T07:44:40+00:00" + "time": "2018-10-31T16:06:48+00:00" }, { "name": "phpunit/php-file-iterator", - "version": "1.4.2", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5" + "reference": "050bedf145a257b1ff02746c31894800e5122946" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/3cc8f69b3028d0f96a9078e6295d86e9bf019be5", - "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/050bedf145a257b1ff02746c31894800e5122946", + "reference": "050bedf145a257b1ff02746c31894800e5122946", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^7.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4.x-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { @@ -1149,7 +1603,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -1159,7 +1613,7 @@ "filesystem", "iterator" ], - "time": "2016-10-03T07:40:28+00:00" + "time": "2018-09-13T20:33:42+00:00" }, { "name": "phpunit/php-text-template", @@ -1204,28 +1658,28 @@ }, { "name": "phpunit/php-timer", - "version": "1.0.9", + "version": "2.1.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f" + "reference": "1038454804406b0b5f5f520358e78c1c2f71501e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", - "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/1038454804406b0b5f5f520358e78c1c2f71501e", + "reference": "1038454804406b0b5f5f520358e78c1c2f71501e", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0" + "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" + "phpunit/phpunit": "^7.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "2.1-dev" } }, "autoload": { @@ -1240,7 +1694,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -1249,33 +1703,33 @@ "keywords": [ "timer" ], - "time": "2017-02-26T11:10:40+00:00" + "time": "2019-06-07T04:22:29+00:00" }, { "name": "phpunit/php-token-stream", - "version": "1.4.11", + "version": "3.1.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7" + "reference": "995192df77f63a59e47f025390d2d1fdf8f425ff" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/e03f8f67534427a787e21a385a67ec3ca6978ea7", - "reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/995192df77f63a59e47f025390d2d1fdf8f425ff", + "reference": "995192df77f63a59e47f025390d2d1fdf8f425ff", "shasum": "" }, "require": { "ext-tokenizer": "*", - "php": ">=5.3.3" + "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "~4.2" + "phpunit/phpunit": "^7.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4-dev" + "dev-master": "3.1-dev" } }, "autoload": { @@ -1298,55 +1752,57 @@ "keywords": [ "tokenizer" ], - "time": "2017-02-27T10:12:30+00:00" + "time": "2019-09-17T06:23:10+00:00" }, { "name": "phpunit/phpunit", - "version": "5.7.19", + "version": "7.5.17", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "69c4f49ff376af2692bad9cebd883d17ebaa98a1" + "reference": "4c92a15296e58191a4cd74cff3b34fc8e374174a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/69c4f49ff376af2692bad9cebd883d17ebaa98a1", - "reference": "69c4f49ff376af2692bad9cebd883d17ebaa98a1", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/4c92a15296e58191a4cd74cff3b34fc8e374174a", + "reference": "4c92a15296e58191a4cd74cff3b34fc8e374174a", "shasum": "" }, "require": { + "doctrine/instantiator": "^1.1", "ext-dom": "*", "ext-json": "*", "ext-libxml": "*", "ext-mbstring": "*", "ext-xml": "*", - "myclabs/deep-copy": "~1.3", - "php": "^5.6 || ^7.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.2.4", - "sebastian/diff": "~1.2", - "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.3|~2.0", - "symfony/yaml": "~2.1|~3.0" + "myclabs/deep-copy": "^1.7", + "phar-io/manifest": "^1.0.2", + "phar-io/version": "^2.0", + "php": "^7.1", + "phpspec/prophecy": "^1.7", + "phpunit/php-code-coverage": "^6.0.7", + "phpunit/php-file-iterator": "^2.0.1", + "phpunit/php-text-template": "^1.2.1", + "phpunit/php-timer": "^2.1", + "sebastian/comparator": "^3.0", + "sebastian/diff": "^3.0", + "sebastian/environment": "^4.0", + "sebastian/exporter": "^3.1", + "sebastian/global-state": "^2.0", + "sebastian/object-enumerator": "^3.0.3", + "sebastian/resource-operations": "^2.0", + "sebastian/version": "^2.0.1" }, "conflict": { - "phpdocumentor/reflection-docblock": "3.0.2" + "phpunit/phpunit-mock-objects": "*" }, "require-dev": { "ext-pdo": "*" }, "suggest": { + "ext-soap": "*", "ext-xdebug": "*", - "phpunit/php-invoker": "~1.1" + "phpunit/php-invoker": "^2.0" }, "bin": [ "phpunit" @@ -1354,7 +1810,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "5.7.x-dev" + "dev-master": "7.5-dev" } }, "autoload": { @@ -1380,66 +1836,7 @@ "testing", "xunit" ], - "time": "2017-04-03T02:22:27+00:00" - }, - { - "name": "phpunit/phpunit-mock-objects", - "version": "3.4.3", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "3ab72b65b39b491e0c011e2e09bb2206c2aa8e24" - }, - "dist": { - "type": "zip", - "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 || ^2.0" - }, - "conflict": { - "phpunit/phpunit": "<5.4.0" - }, - "require-dev": { - "phpunit/phpunit": "^5.4" - }, - "suggest": { - "ext-soap": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.2.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Mock Object library for PHPUnit", - "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", - "keywords": [ - "mock", - "xunit" - ], - "time": "2016-12-08T20:27:08+00:00" + "time": "2019-10-28T10:37:36+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", @@ -1488,30 +1885,30 @@ }, { "name": "sebastian/comparator", - "version": "1.2.4", + "version": "3.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be" + "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", - "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/5de4fc177adf9bce8df98d8d141a7559d7ccf6da", + "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da", "shasum": "" }, "require": { - "php": ">=5.3.3", - "sebastian/diff": "~1.2", - "sebastian/exporter": "~1.2 || ~2.0" + "php": "^7.1", + "sebastian/diff": "^3.0", + "sebastian/exporter": "^3.1" }, "require-dev": { - "phpunit/phpunit": "~4.4" + "phpunit/phpunit": "^7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2.x-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -1542,38 +1939,39 @@ } ], "description": "Provides the functionality to compare PHP values for equality", - "homepage": "http://www.github.com/sebastianbergmann/comparator", + "homepage": "https://github.com/sebastianbergmann/comparator", "keywords": [ "comparator", "compare", "equality" ], - "time": "2017-01-29T09:50:25+00:00" + "time": "2018-07-12T15:12:46+00:00" }, { "name": "sebastian/diff", - "version": "1.4.1", + "version": "3.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "13edfd8706462032c2f52b4b862974dd46b71c9e" + "reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/13edfd8706462032c2f52b4b862974dd46b71c9e", - "reference": "13edfd8706462032c2f52b4b862974dd46b71c9e", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/720fcc7e9b5cf384ea68d9d930d480907a0c1a29", + "reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "~4.8" + "phpunit/phpunit": "^7.5 || ^8.0", + "symfony/process": "^2 || ^3.3 || ^4" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -1598,34 +1996,40 @@ "description": "Diff implementation", "homepage": "https://github.com/sebastianbergmann/diff", "keywords": [ - "diff" + "diff", + "udiff", + "unidiff", + "unified diff" ], - "time": "2015-12-08T07:14:41+00:00" + "time": "2019-02-04T06:01:07+00:00" }, { "name": "sebastian/environment", - "version": "2.0.0", + "version": "4.2.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "5795ffe5dc5b02460c3e34222fee8cbe245d8fac" + "reference": "464c90d7bdf5ad4e8a6aea15c091fec0603d4368" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/5795ffe5dc5b02460c3e34222fee8cbe245d8fac", - "reference": "5795ffe5dc5b02460c3e34222fee8cbe245d8fac", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/464c90d7bdf5ad4e8a6aea15c091fec0603d4368", + "reference": "464c90d7bdf5ad4e8a6aea15c091fec0603d4368", "shasum": "" }, "require": { - "php": "^5.6 || ^7.0" + "php": "^7.1" }, "require-dev": { - "phpunit/phpunit": "^5.0" + "phpunit/phpunit": "^7.5" + }, + "suggest": { + "ext-posix": "*" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "4.2-dev" } }, "autoload": { @@ -1650,34 +2054,34 @@ "environment", "hhvm" ], - "time": "2016-11-26T07:53:53+00:00" + "time": "2019-11-20T08:46:58+00:00" }, { "name": "sebastian/exporter", - "version": "2.0.0", + "version": "3.1.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4" + "reference": "68609e1261d215ea5b21b7987539cbfbe156ec3e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4", - "reference": "ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/68609e1261d215ea5b21b7987539cbfbe156ec3e", + "reference": "68609e1261d215ea5b21b7987539cbfbe156ec3e", "shasum": "" }, "require": { - "php": ">=5.3.3", - "sebastian/recursion-context": "~2.0" + "php": "^7.0", + "sebastian/recursion-context": "^3.0" }, "require-dev": { "ext-mbstring": "*", - "phpunit/phpunit": "~4.4" + "phpunit/phpunit": "^6.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "3.1.x-dev" } }, "autoload": { @@ -1690,6 +2094,10 @@ "BSD-3-Clause" ], "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, { "name": "Jeff Welch", "email": "whatthejeff@gmail.com" @@ -1698,17 +2106,13 @@ "name": "Volker Dusch", "email": "github@wallbash.com" }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, { "name": "Adam Harvey", "email": "aharvey@php.net" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" } ], "description": "Provides the functionality to export PHP variables for visualization", @@ -1717,27 +2121,27 @@ "export", "exporter" ], - "time": "2016-11-19T08:54:04+00:00" + "time": "2019-09-14T09:02:43+00:00" }, { "name": "sebastian/global-state", - "version": "1.1.1", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4" + "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bc37d50fea7d017d3d340f230811c9f1d7280af4", - "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", + "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^7.0" }, "require-dev": { - "phpunit/phpunit": "~4.2" + "phpunit/phpunit": "^6.0" }, "suggest": { "ext-uopz": "*" @@ -1745,7 +2149,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -1768,33 +2172,34 @@ "keywords": [ "global state" ], - "time": "2015-10-12T03:26:01+00:00" + "time": "2017-04-27T15:39:26+00:00" }, { "name": "sebastian/object-enumerator", - "version": "2.0.1", + "version": "3.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "1311872ac850040a79c3c058bea3e22d0f09cbb7" + "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/1311872ac850040a79c3c058bea3e22d0f09cbb7", - "reference": "1311872ac850040a79c3c058bea3e22d0f09cbb7", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/7cfd9e65d11ffb5af41198476395774d4c8a84c5", + "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5", "shasum": "" }, "require": { - "php": ">=5.6", - "sebastian/recursion-context": "~2.0" + "php": "^7.0", + "sebastian/object-reflector": "^1.1.1", + "sebastian/recursion-context": "^3.0" }, "require-dev": { - "phpunit/phpunit": "~5" + "phpunit/phpunit": "^6.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "3.0.x-dev" } }, "autoload": { @@ -1814,32 +2219,77 @@ ], "description": "Traverses array structures and object graphs to enumerate all referenced objects", "homepage": "https://github.com/sebastianbergmann/object-enumerator/", - "time": "2017-02-18T15:18:39+00:00" + "time": "2017-08-03T12:35:26+00:00" + }, + { + "name": "sebastian/object-reflector", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-reflector.git", + "reference": "773f97c67f28de00d397be301821b06708fca0be" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/773f97c67f28de00d397be301821b06708fca0be", + "reference": "773f97c67f28de00d397be301821b06708fca0be", + "shasum": "" + }, + "require": { + "php": "^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Allows reflection of object attributes, including inherited and non-public ones", + "homepage": "https://github.com/sebastianbergmann/object-reflector/", + "time": "2017-03-29T09:07:27+00:00" }, { "name": "sebastian/recursion-context", - "version": "2.0.0", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "2c3ba150cbec723aa057506e73a8d33bdb286c9a" + "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/2c3ba150cbec723aa057506e73a8d33bdb286c9a", - "reference": "2c3ba150cbec723aa057506e73a8d33bdb286c9a", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", + "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^7.0" }, "require-dev": { - "phpunit/phpunit": "~4.4" + "phpunit/phpunit": "^6.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "3.0.x-dev" } }, "autoload": { @@ -1867,29 +2317,29 @@ ], "description": "Provides functionality to recursively process PHP variables", "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2016-11-19T07:33:16+00:00" + "time": "2017-03-03T06:23:57+00:00" }, { "name": "sebastian/resource-operations", - "version": "1.0.0", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52" + "reference": "4d7a795d35b889bf80a0cc04e08d77cedfa917a9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", - "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/4d7a795d35b889bf80a0cc04e08d77cedfa917a9", + "reference": "4d7a795d35b889bf80a0cc04e08d77cedfa917a9", "shasum": "" }, "require": { - "php": ">=5.6.0" + "php": "^7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -1909,7 +2359,7 @@ ], "description": "Provides a list of PHP built-in functions that operate on resources", "homepage": "https://www.github.com/sebastianbergmann/resource-operations", - "time": "2015-07-28T20:34:47+00:00" + "time": "2018-10-04T04:07:39+00:00" }, { "name": "sebastian/version", @@ -1956,16 +2406,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "2.8.1", + "version": "2.9.2", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "d7cf0d894e8aa4c73712ee4a331cc1eaa37cdc7d" + "reference": "2acf168de78487db620ab4bc524135a13cfe6745" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/d7cf0d894e8aa4c73712ee4a331cc1eaa37cdc7d", - "reference": "d7cf0d894e8aa4c73712ee4a331cc1eaa37cdc7d", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/2acf168de78487db620ab4bc524135a13cfe6745", + "reference": "2acf168de78487db620ab4bc524135a13cfe6745", "shasum": "" }, "require": { @@ -2030,43 +2480,40 @@ "phpcs", "standards" ], - "time": "2017-03-01T22:17:45+00:00" + "time": "2018-11-07T22:31:41+00:00" }, { - "name": "symfony/yaml", - "version": "v3.2.7", + "name": "symfony/polyfill-ctype", + "version": "v1.13.1", "source": { "type": "git", - "url": "https://github.com/symfony/yaml.git", - "reference": "62b4cdb99d52cb1ff253c465eb1532a80cebb621" + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/62b4cdb99d52cb1ff253c465eb1532a80cebb621", - "reference": "62b4cdb99d52cb1ff253c465eb1532a80cebb621", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/f8f0b461be3385e56d6de3dbb5a0df24c0c275e3", + "reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3", "shasum": "" }, "require": { - "php": ">=5.5.9" - }, - "require-dev": { - "symfony/console": "~2.8|~3.0" + "php": ">=5.3.3" }, "suggest": { - "symfony/console": "For validating YAML files using the lint command" + "ext-ctype": "For best performance" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.2-dev" + "dev-master": "1.13-dev" } }, "autoload": { "psr-4": { - "Symfony\\Component\\Yaml\\": "" + "Symfony\\Polyfill\\Ctype\\": "" }, - "exclude-from-classmap": [ - "/Tests/" + "files": [ + "bootstrap.php" ] }, "notification-url": "https://packagist.org/downloads/", @@ -2075,45 +2522,89 @@ ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony Yaml Component", + "description": "Symfony polyfill for ctype functions", "homepage": "https://symfony.com", - "time": "2017-03-20T09:45:15+00:00" + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "time": "2019-11-27T13:56:44+00:00" + }, + { + "name": "theseer/tokenizer", + "version": "1.1.3", + "source": { + "type": "git", + "url": "https://github.com/theseer/tokenizer.git", + "reference": "11336f6f84e16a720dae9d8e6ed5019efa85a0f9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/11336f6f84e16a720dae9d8e6ed5019efa85a0f9", + "reference": "11336f6f84e16a720dae9d8e6ed5019efa85a0f9", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": "^7.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + } + ], + "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", + "time": "2019-06-13T22:48:21+00:00" }, { "name": "webmozart/assert", - "version": "1.2.0", + "version": "1.6.0", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f" + "reference": "573381c0a64f155a0d9a23f4b0c797194805b925" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/2db61e59ff05fe5126d152bd0655c9ea113e550f", - "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f", + "url": "https://api.github.com/repos/webmozart/assert/zipball/573381c0a64f155a0d9a23f4b0c797194805b925", + "reference": "573381c0a64f155a0d9a23f4b0c797194805b925", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0" + "php": "^5.3.3 || ^7.0", + "symfony/polyfill-ctype": "^1.8" + }, + "conflict": { + "vimeo/psalm": "<3.6.0" }, "require-dev": { - "phpunit/phpunit": "^4.6", - "sebastian/version": "^1.0.1" + "phpunit/phpunit": "^4.8.36 || ^7.5.13" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3-dev" - } - }, "autoload": { "psr-4": { "Webmozart\\Assert\\": "src/" @@ -2135,7 +2626,7 @@ "check", "validate" ], - "time": "2016-11-23T20:04:58+00:00" + "time": "2019-11-24T13:36:37+00:00" } ], "aliases": [], @@ -2144,7 +2635,8 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=5.6.0" + "php": "^7.2", + "ext-json": "*" }, "platform-dev": [] } diff --git a/examples/cache/Laravel.php b/examples/cache/Laravel.php deleted file mode 100644 index a88bb1a..0000000 --- a/examples/cache/Laravel.php +++ /dev/null @@ -1,33 +0,0 @@ -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 deleted file mode 100644 index 08e59c3..0000000 --- a/examples/cache/phpFastCache.php +++ /dev/null @@ -1,36 +0,0 @@ - '/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/phpunit.xml b/phpunit.xml index 051430e..e649c1e 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,8 +1,8 @@ - - ./Tests/ + + ./tests/Unit diff --git a/readme.md b/readme.md index 6a14fb9..f5a341a 100644 --- a/readme.md +++ b/readme.md @@ -1,90 +1,48 @@ -# TruckersMP REST API Library +

-[![Build Status](https://travis-ci.org/TruckersMP/API-Client.svg?branch=master)](https://travis-ci.org/TruckersMP/API-Client) -[![StyleCI Status](https://github.styleci.io/repos/57324164/shield?branch=master)](https://github.styleci.io/repos/57324164) -[![Latest Stable Version](https://poser.pugx.org/truckersmp/api-client/v/stable)](https://packagist.org/packages/truckersmp/api-client) -[![Latest Unstable Version](https://poser.pugx.org/truckersmp/api-client/v/unstable)](https://packagist.org/packages/truckersmp/api-client) -[![License](https://poser.pugx.org/truckersmp/api-client/license)](https://packagist.org/packages/truckersmp/api-client) -[![Monthly Downloads](https://poser.pugx.org/truckersmp/api-client/d/monthly)](https://packagist.org/packages/truckersmp/api-client) -[![Total Downloads](https://poser.pugx.org/truckersmp/api-client/downloads)](https://packagist.org/packages/truckersmp/api-client) +

+Build Status +StyleCI Status +Total Downloads +Latest Stable Version +Latest Unstable Version +License +

+## Introduction -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. +The TruckersMP PHP library provides convenient access to the TruckersMP API for applications written in the PHP +language. It includes a pre-defined set of classes for API each endpoint to get the data as a collection or model. -> 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). +If you want to use the API without the library, check out the [API Documentation](https://stats.truckersmp.com/api). -## Warning! +## Requirements -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 7.1.0 or newer +- PHP 7.2 or later - Composer -## Installation +## Composer -This library can be installed using [Composer](http://getcomposer.org/). +You can install the package via [Composer](https://getcomposer.org). Run the following command: -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, execute the command `composer install`. - -## Usage +```bash +composer require truckersmp/api-client +``` -> **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.** +To use the package, use Composer's [autoload](https://getcomposer.org/doc/01-basic-usage.md#autoloading): ```php -player(50); - -// Get player data for player with SteamID 76561197965863564 -$player = $client->player(76561197965863564); - -// output the user's name -echo $player->name; - -// output the user's group -echo $player->groupName; - +require_once('vendor/autoload.php'); ``` -## 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 +## Official Documentation -## 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 -request = new Request($url, $config); - } - - /** - * Fetch player information. - * - * @param int $id - * - * @throws \Exception - * @throws \Http\Client\Exception - * - * @return \TruckersMP\Types\Player - */ - public function player($id) - { - $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) - { - $result = $this->request->execute('bans/' . $id); - - return new Bans($result); - } - - /** - * @throws \Exception - * @throws \Http\Client\Exception - * - * @return \TruckersMP\Types\Servers - */ - public function servers() - { - $result = $this->request->execute('servers'); - - return new Servers($result); - } - - /** - * @throws \Exception - * @throws \Http\Client\Exception - * - * @return \TruckersMP\Types\GameTime - */ - public function gameTime() - { - $result = $this->request->execute('game_time'); - - return new GameTime($result); - } - - /** - * @throws \Exception - * @throws \Http\Client\Exception - * - * @return \TruckersMP\Types\Version - */ - public function version() - { - $result = $this->request->execute('version'); - - return new Version($result); - } -} diff --git a/src/API/Request.php b/src/API/Request.php deleted file mode 100644 index 688f65b..0000000 --- a/src/API/Request.php +++ /dev/null @@ -1,57 +0,0 @@ -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/ApiErrorHandler.php b/src/ApiErrorHandler.php new file mode 100644 index 0000000..9d76fb3 --- /dev/null +++ b/src/ApiErrorHandler.php @@ -0,0 +1,41 @@ + $ban) { + $this->items[$key] = new Ban($ban); + } + } +} diff --git a/src/Collections/Collection.php b/src/Collections/Collection.php new file mode 100644 index 0000000..2836a66 --- /dev/null +++ b/src/Collections/Collection.php @@ -0,0 +1,145 @@ +position = 0; + } + + /** + * Determine if an item exists at an offset. + * + * @param mixed $key + * + * @return bool + */ + public function offsetExists($key) + { + return array_key_exists($key, $this->items); + } + + /** + * Get an item at a given offset. + * + * @param mixed $key + * + * @return mixed + */ + public function offsetGet($key) + { + return $this->items[$key]; + } + + /** + * Set the item at a given offset. + * + * @param mixed $key + * @param mixed $value + * + * @return void + */ + public function offsetSet($key, $value) + { + if (is_null($key)) { + $this->items[] = $value; + } else { + $this->items[$key] = $value; + } + } + + /** + * Unset the item at a given offset. + * + * @param string $key + * + * @return void + */ + public function offsetUnset($key) + { + unset($this->items[$key]); + } + + /** + * Return the current element. + * + * @return mixed + */ + public function current() + { + return $this->items[$this->position]; + } + + /** + * Move forward to next element. + * + * @return void + */ + public function next() + { + $this->position++; + } + + /** + * Return the key of the current element. + * + * @return int + */ + public function key(): int + { + return $this->position; + } + + /** + * Checks if current position is valid. + * + * @return bool + */ + public function valid(): bool + { + return isset($this->items[$this->position]); + } + + /** + * Rewind the Iterator to the first element. + * + * @return void + */ + public function rewind() + { + $this->position = 0; + } + + /** + * Count elements of an object. + * + * @return int + */ + public function count(): int + { + return count($this->items); + } +} diff --git a/src/Collections/Company/MemberCollection.php b/src/Collections/Company/MemberCollection.php new file mode 100644 index 0000000..bf3a226 --- /dev/null +++ b/src/Collections/Company/MemberCollection.php @@ -0,0 +1,23 @@ + $member) { + $this->items[$key] = new CompanyMember($member); + } + } +} diff --git a/src/Collections/Company/PostCollection.php b/src/Collections/Company/PostCollection.php new file mode 100644 index 0000000..eec12fd --- /dev/null +++ b/src/Collections/Company/PostCollection.php @@ -0,0 +1,23 @@ + $post) { + $this->items[$key] = new CompanyPost($post); + } + } +} diff --git a/src/Collections/Company/RoleCollection.php b/src/Collections/Company/RoleCollection.php new file mode 100644 index 0000000..8af5a8d --- /dev/null +++ b/src/Collections/Company/RoleCollection.php @@ -0,0 +1,25 @@ + $role) { + $this->items[$key] = new CompanyRole($role); + } + } +} diff --git a/src/Collections/CompanyCollection.php b/src/Collections/CompanyCollection.php new file mode 100644 index 0000000..b87d0b3 --- /dev/null +++ b/src/Collections/CompanyCollection.php @@ -0,0 +1,24 @@ + $company) { + $this->items[$key] = new Company($company); + } + } +} diff --git a/src/Collections/ServerCollection.php b/src/Collections/ServerCollection.php new file mode 100644 index 0000000..39c244a --- /dev/null +++ b/src/Collections/ServerCollection.php @@ -0,0 +1,22 @@ + $server) { + $this->items[$key] = new Server($server); + } + } +} diff --git a/src/Exceptions/APIErrorException.php b/src/Exceptions/APIErrorException.php deleted file mode 100644 index 28749af..0000000 --- a/src/Exceptions/APIErrorException.php +++ /dev/null @@ -1,13 +0,0 @@ -expiration = new Carbon($ban['expiration'], 'UTC'); + } else { + $this->expiration = null; + } + + // Time Added + $this->timeAdded = new Carbon($ban['timeAdded'], 'UTC'); + + // Active + $this->active = boolval($ban['active']); + if (!is_null($this->expiration) && $this->active) { + if (!$this->expiration->greaterThan(Carbon::now('UTC'))) { + $this->active = false; + } + } + + $this->reason = $ban['reason']; + $this->adminName = $ban['adminName']; + $this->adminId = intval($ban['adminID']); + } + + /** + * @return \Carbon\Carbon|null + */ + public function getExpirationDate(): ?Carbon + { + return $this->expiration; + } + + /** + * @return \Carbon\Carbon + */ + public function getCreatedAt(): Carbon + { + return $this->timeAdded; + } + + /** + * @return bool + */ + public function isActive(): bool + { + return $this->active; + } + + /** + * @return string + */ + public function getReason(): string + { + return $this->reason; + } + + /** + * @return string + */ + public function getAdminName(): string + { + return $this->adminName; + } + + /** + * @return int + */ + public function getAdminId(): int + { + return $this->adminId; + } +} diff --git a/src/Models/Checksum.php b/src/Models/Checksum.php new file mode 100644 index 0000000..3cfb13d --- /dev/null +++ b/src/Models/Checksum.php @@ -0,0 +1,48 @@ +dll = $dll; + $this->adb = $adb; + } + + /** + * @return string + */ + public function getDLL(): string + { + return $this->dll; + } + + /** + * @return string + */ + public function getADB(): string + { + return $this->adb; + } +} diff --git a/src/Models/Company.php b/src/Models/Company.php new file mode 100644 index 0000000..6cc285a --- /dev/null +++ b/src/Models/Company.php @@ -0,0 +1,373 @@ +id = $company['id']; + $this->name = $company['name']; + $this->ownerId = $company['owner_id']; + $this->ownerName = $company['owner_username']; + $this->slogan = $company['slogan']; + $this->tag = $company['tag']; + + if (array_key_exists('logo', $company)) { + $this->logo = $company['logo']; + } + + if (array_key_exists('cover', $company)) { + $this->cover = $company['cover']; + } + + if (array_key_exists('information', $company)) { + $this->information = $company['information']; + } + + if (array_key_exists('rules', $company)) { + $this->rules = $company['rules']; + } + + if (array_key_exists('requirements', $company)) { + $this->requirements = $company['requirements']; + } + + $this->website = $company['website']; + + $this->social = new Social( + $company['socials']['twitter'], + $company['socials']['facebook'], + $company['socials']['twitch'], + $company['socials']['playstv'], + $company['socials']['discord'], + $company['socials']['youtube'] + ); + + $this->games = new Game( + $company['games']['ats'], + $company['games']['ets'] + ); + + $this->membersCount = intval($company['members_count']); + $this->recruitment = $company['recruitment']; + $this->language = $company['language']; + $this->verified = boolval($company['verified']); + $this->createdAt = new Carbon($company['created'], 'UTC'); + } + + /** + * @return int + */ + public function getId() + { + return $this->id; + } + + /** + * @return string + */ + public function getName(): string + { + return $this->name; + } + + /** + * @return int + */ + public function getOwnerId(): int + { + return $this->ownerId; + } + + /** + * @return string + */ + public function getOwnerName(): string + { + return $this->ownerName; + } + + /** + * @return string + */ + public function getSlogan(): string + { + return $this->slogan; + } + + /** + * @return string + */ + public function getTag(): string + { + return $this->tag; + } + + /** + * @return string + */ + public function getLogo(): string + { + return $this->logo; + } + + /** + * @return string + */ + public function getCover(): string + { + return $this->cover; + } + + /** + * @return string + */ + public function getInformation(): string + { + return $this->information; + } + + /** + * @return string + */ + public function getRules(): string + { + return $this->rules; + } + + /** + * @return string + */ + public function getRequirements(): string + { + return $this->requirements; + } + + /** + * @return string + */ + public function getWebsite(): string + { + return $this->website; + } + + /** + * @return \TruckersMP\Models\Social + */ + public function getSocial(): Social + { + return $this->social; + } + + /** + * @return \TruckersMP\Models\Game + */ + public function getGames(): Game + { + return $this->games; + } + + /** + * @return int + */ + public function getMembersCount(): int + { + return $this->membersCount; + } + + /** + * @return string + */ + public function getRecruitment(): string + { + return $this->recruitment; + } + + /** + * @return string + */ + public function getLanguage(): string + { + return $this->language; + } + + /** + * @return bool + */ + public function isVerified(): bool + { + return $this->verified; + } + + /** + * @return \Carbon\Carbon + */ + public function getCreatedDate(): Carbon + { + return $this->createdAt; + } + + /** + * @return bool + */ + public function isRecruitmentClosed(): bool + { + return $this->recruitment === self::RECRUITMENT_CLOSED; + } + + /** + * @return bool + */ + public function isRecruitmentOpen(): bool + { + return !$this->isRecruitmentClosed(); + } +} diff --git a/src/Models/CompanyIndex.php b/src/Models/CompanyIndex.php new file mode 100644 index 0000000..28acc11 --- /dev/null +++ b/src/Models/CompanyIndex.php @@ -0,0 +1,69 @@ +recent = new CompanyCollection($response['recent']); + + $this->featured = new CompanyCollection($response['featured']); + + $this->featuredCovered = new CompanyCollection($response['featured_cover']); + } + + /** + * @return \TruckersMP\Collections\CompanyCollection + */ + public function getRecent(): CompanyCollection + { + return $this->recent; + } + + /** + * @return \TruckersMP\Collections\CompanyCollection + */ + public function getFeatured(): CompanyCollection + { + return $this->featured; + } + + /** + * @return \TruckersMP\Collections\CompanyCollection + */ + public function getFeaturedCovered(): CompanyCollection + { + return $this->featuredCovered; + } +} diff --git a/src/Models/CompanyMember.php b/src/Models/CompanyMember.php new file mode 100644 index 0000000..85cab98 --- /dev/null +++ b/src/Models/CompanyMember.php @@ -0,0 +1,129 @@ +id = $member['id']; + $this->userId = $member['user_id']; + $this->username = $member['username']; + $this->steamId = $member['steam_id']; + $this->roleId = $member['role_id']; + $this->role = $member['role']; + $this->joinDate = new Carbon($member['joinDate'], 'UTC'); + } + + /** + * @return int + */ + public function getId(): int + { + return $this->id; + } + + /** + * @return int + */ + public function getUserId(): int + { + return $this->userId; + } + + /** + * @return string + */ + public function getUsername(): string + { + return $this->username; + } + + /** + * @return string + */ + public function getSteamId(): string + { + return $this->steamId; + } + + /** + * @return int + */ + public function getRoleId(): int + { + return $this->roleId; + } + + /** + * @return string + */ + public function getRole(): string + { + return $this->role; + } + + /** + * @return \Carbon\Carbon + */ + public function getJoinDate(): Carbon + { + return $this->joinDate; + } +} diff --git a/src/Models/CompanyMemberIndex.php b/src/Models/CompanyMemberIndex.php new file mode 100644 index 0000000..dc5ea63 --- /dev/null +++ b/src/Models/CompanyMemberIndex.php @@ -0,0 +1,50 @@ +members = new MemberCollection($response['members']); + + $this->count = $response['members_count']; + } + + /** + * @return \TruckersMP\APIClient\Collections\MemberCollection + */ + public function getMembers(): MemberCollection + { + return $this->members; + } + + /** + * @return int + */ + public function getCount(): int + { + return $this->count; + } +} diff --git a/src/Models/CompanyPost.php b/src/Models/CompanyPost.php new file mode 100644 index 0000000..b647058 --- /dev/null +++ b/src/Models/CompanyPost.php @@ -0,0 +1,131 @@ +id = $post['id']; + $this->title = $post['title']; + $this->summary = $post['content_summary']; + + if (isset($post['content'])) { + $this->content = $post['content']; + } + + $this->authorId = $post['author_id']; + $this->author = $post['author']; + $this->pinned = $post['pinned']; + } + + /** + * @return int + */ + public function getId(): int + { + return $this->id; + } + + /** + * @return string + */ + public function getTitle(): string + { + return $this->title; + } + + /** + * @return string + */ + public function getSummary(): string + { + return $this->summary; + } + + /** + * @return string + */ + public function getContent(): string + { + return $this->content; + } + + /** + * @return int + */ + public function getAuthorId(): int + { + return $this->authorId; + } + + /** + * @return string + */ + public function getAuthor(): string + { + return $this->author; + } + + /** + * @return bool + */ + public function isPinned(): bool + { + return $this->pinned; + } +} diff --git a/src/Models/CompanyRole.php b/src/Models/CompanyRole.php new file mode 100644 index 0000000..2f427eb --- /dev/null +++ b/src/Models/CompanyRole.php @@ -0,0 +1,115 @@ +id = $role['id']; + $this->name = $role['name']; + $this->order = $role['order']; + $this->owner = $role['owner']; + $this->createdAt = new Carbon($role['created_at'], 'UTC'); + $this->updatedAt = new Carbon($role['updated_at'], 'UTC'); + } + + /** + * @return int + */ + public function getId(): int + { + return $this->id; + } + + /** + * @return string + */ + public function getName(): string + { + return $this->name; + } + + /** + * @return int + */ + public function getOrder(): int + { + return $this->order; + } + + /** + * @return bool + */ + public function isOwner(): bool + { + return $this->owner; + } + + /** + * @return \Carbon\Carbon + */ + public function getCreatedAt(): Carbon + { + return $this->createdAt; + } + + /** + * @return \Carbon\Carbon + */ + public function getUpdatedAt(): Carbon + { + return $this->updatedAt; + } +} diff --git a/src/Models/Game.php b/src/Models/Game.php new file mode 100644 index 0000000..e628106 --- /dev/null +++ b/src/Models/Game.php @@ -0,0 +1,44 @@ +ats = $ats; + $this->ets = $ets; + } + + /** + * @return bool + */ + public function isAts(): bool + { + return $this->ats; + } + + /** + * @return bool + */ + public function isEts(): bool + { + return $this->ets; + } +} diff --git a/src/Models/GameTime.php b/src/Models/GameTime.php new file mode 100644 index 0000000..0f28db9 --- /dev/null +++ b/src/Models/GameTime.php @@ -0,0 +1,53 @@ +time = Carbon::create( + $time['years'], + $time['months'], + $time['days'], + $time['hours'], + $time['minutes'] + ); + } + + /** + * @return \Carbon\Carbon + */ + public function getTime(): Carbon + { + return $this->time; + } +} diff --git a/src/Models/Player.php b/src/Models/Player.php new file mode 100644 index 0000000..a38c831 --- /dev/null +++ b/src/Models/Player.php @@ -0,0 +1,362 @@ +id = $player['id']; + $this->name = $player['name']; + $this->avatar = $player['avatar']; + $this->smallAvatar = $player['smallAvatar']; + $this->joinDate = new Carbon($player['joinDate'], 'UTC'); + $this->steamID64 = $player['steamID64']; + $this->groupId = $player['groupID']; + $this->groupName = $player['groupName']; + $this->isBanned = $player['banned']; + $this->bannedUntil = new Carbon($player['bannedUntil'], 'UTC'); + $this->displayBans = $player['displayBans']; + $this->inGameAdmin = $player['permissions']['isGameAdmin']; + $this->companyId = $player['vtc']['id']; + $this->companyName = $player['vtc']['name']; + $this->companyTag = $player['vtc']['tag']; + $this->isInCompany = $player['vtc']['inVTC']; + $this->companyMemberId = $player['vtc']['memberID']; + } + + /** + * @return int + */ + public function getId(): int + { + return $this->id; + } + + /** + * @return string + */ + public function getName(): string + { + return $this->name; + } + + /** + * @return string + */ + public function getAvatar(): string + { + return $this->avatar; + } + + /** + * @return string + */ + public function getSmallAvatar(): string + { + return $this->smallAvatar; + } + + /** + * @return Carbon + */ + public function getJoinDate(): Carbon + { + return $this->joinDate; + } + + /** + * @return string + */ + public function getSteamID64(): string + { + return $this->steamID64; + } + + /** + * @return int + */ + public function getGroupId(): int + { + return $this->groupId; + } + + /** + * @return string + */ + public function getGroupName(): string + { + return $this->groupName; + } + + /** + * @return bool + */ + public function isBanned(): bool + { + return $this->isBanned; + } + + /** + * @return \Carbon\Carbon|null + */ + public function getBannedUntilDate(): ?Carbon + { + return $this->bannedUntil; + } + + /** + * @return bool + */ + public function hasBansHidden(): bool + { + return !$this->displayBans; + } + + /** + * @return bool + */ + public function isAdmin(): bool + { + return $this->inGameAdmin; + } + + /** + * @return int + */ + public function getCompanyId(): int + { + return $this->companyId; + } + + /** + * @return string + */ + public function getCompanyName(): string + { + return $this->companyName; + } + + /** + * @return string + */ + public function getCompanyTag(): string + { + return $this->companyTag; + } + + /** + * @return bool + */ + public function isInCompany(): bool + { + return $this->isInCompany; + } + + /** + * @return int + */ + public function getCompanyMemberId(): int + { + return $this->companyMemberId; + } + + /** + * @return \TruckersMP\Collections\BanCollection + * + * @throws \Http\Client\Exception + * @throws \TruckersMP\Exceptions\PageNotFoundException + * @throws \TruckersMP\Exceptions\RequestException + */ + public function getBans(): BanCollection + { + return (new BanRequest($this->id))->get(); + } + + /** + * @return \TruckersMP\Models\Company|null + * + * @throws \Http\Client\Exception + * @throws \TruckersMP\Exceptions\PageNotFoundException + * @throws \TruckersMP\Exceptions\RequestException + */ + public function getCompany(): ?Company + { + $company = null; + + if ($this->isInCompany()) { + $company = (new CompanyRequest($this->companyId))->get(); + } + + return $company; + } + + /** + * @return \TruckersMP\Models\CompanyMember|null + * + * @throws \Http\Client\Exception + * @throws \TruckersMP\Exceptions\PageNotFoundException + * @throws \TruckersMP\Exceptions\RequestException + */ + public function getCompanyMember(): ?CompanyMember + { + $member = null; + + if ($this->isInCompany()) { + $member = (new MemberRequest($this->companyId, $this->companyMemberId))->get(); + } + + return $member; + } + + /** + * @return \TruckersMP\Models\CompanyRole|null + * + * @throws \Http\Client\Exception + * @throws \TruckersMP\Exceptions\PageNotFoundException + * @throws \TruckersMP\Exceptions\RequestException + */ + public function getCompanyRole(): ?CompanyRole + { + $role = null; + + if ($this->isInCompany()) { + $role = (new RoleRequest($this->companyId, $this->getCompanyMember()->getRoleId()))->get(); + } + + return $role; + } +} diff --git a/src/Models/Rule.php b/src/Models/Rule.php new file mode 100644 index 0000000..b303fd8 --- /dev/null +++ b/src/Models/Rule.php @@ -0,0 +1,47 @@ +rules = $rules['rules']; + $this->revision = $rules['revision']; + } + + /** + * @return string + */ + public function getRules(): string + { + return $this->rules; + } + + /** + * @return int + */ + public function getRevision(): int + { + return $this->revision; + } +} diff --git a/src/Models/Server.php b/src/Models/Server.php new file mode 100644 index 0000000..39cf81c --- /dev/null +++ b/src/Models/Server.php @@ -0,0 +1,351 @@ +id = $server['id']; + $this->game = $server['game']; + $this->ip = $server['ip']; + $this->port = intval($server['port']); + $this->name = $server['name']; + $this->shortName = $server['shortname']; + $this->idPrefix = $server['idprefix']; + $this->online = boolval($server['online']); + $this->players = intval($server['players']); + $this->queue = intval($server['queue']); + $this->maxPlayers = intval($server['maxplayers']); + $this->displayOrder = intval($server['displayorder']); + $this->speedLimiter = boolval($server['speedlimiter']); + $this->collisions = boolval($server['collisions']); + $this->carsForPlayers = boolval($server['carsforplayers']); + $this->policeCarsForPlayers = boolval($server['policecarsforplayers']); + $this->afkEnabled = boolval($server['afkenabled']); + $this->event = boolval($server['event']); + $this->specialEvent = boolval($server['specialEvent']); + $this->promods = boolval($server['promods']); + $this->syncDelay = intval($server['syncdelay']); + } + + /** + * @return int + */ + public function getId() + { + return $this->id; + } + + /** + * @return string + */ + public function getGame(): string + { + return $this->game; + } + + /** + * @return string + */ + public function getIp(): string + { + return $this->ip; + } + + /** + * @return int + */ + public function getPort(): int + { + return $this->port; + } + + /** + * @return string + */ + public function getName(): string + { + return $this->name; + } + + /** + * @return string + */ + public function getShortName(): string + { + return $this->shortName; + } + + /** + * @return string|null + */ + public function getIdPrefix(): ?string + { + return $this->idPrefix; + } + + /** + * @return bool + */ + public function isOnline(): bool + { + return $this->online; + } + + /** + * @return int + */ + public function getPlayers(): int + { + return $this->players; + } + + /** + * @return int + */ + public function getQueue(): int + { + return $this->queue; + } + + /** + * @return int + */ + public function getMaxPlayers(): int + { + return $this->maxPlayers; + } + + /** + * @return int + */ + public function getDisplayOrder(): int + { + return $this->displayOrder; + } + + /** + * @return bool + */ + public function hasSpeedLimit(): bool + { + return $this->speedLimiter; + } + + /** + * @return bool + */ + public function hasCollisions(): bool + { + return $this->collisions; + } + + /** + * @return bool + */ + public function canPlayersHaveCars(): bool + { + return $this->carsForPlayers; + } + + /** + * @return bool + */ + public function canPlayersHavePoliceCars(): bool + { + return $this->policeCarsForPlayers; + } + + /** + * @return bool + */ + public function isAfkEnabled(): bool + { + return $this->afkEnabled; + } + + /** + * @return bool + */ + public function isEvent(): bool + { + return $this->event; + } + + /** + * @return bool + */ + public function isSpecialEvent(): bool + { + return $this->specialEvent; + } + + /** + * @return bool + */ + public function hasPromods(): bool + { + return $this->promods; + } + + /** + * @return int + */ + public function getSyncDelay(): int + { + return $this->syncDelay; + } +} diff --git a/src/Models/Social.php b/src/Models/Social.php new file mode 100644 index 0000000..0abefce --- /dev/null +++ b/src/Models/Social.php @@ -0,0 +1,110 @@ +twitter = $twitter; + $this->facebook = $facebook; + $this->twitch = $twitch; + $this->plays = $plays; + $this->discord = $discord; + $this->youtube = $youtube; + } + + /** + * @return string|null + */ + public function getTwitter(): ?string + { + return $this->twitter; + } + + /** + * @return string|null + */ + public function getFacebook(): ?string + { + return $this->facebook; + } + + /** + * @return string|null + */ + public function getTwitch(): ?string + { + return $this->twitch; + } + + /** + * @return string|null + */ + public function getPlays(): ?string + { + return $this->plays; + } + + /** + * @return string|null + */ + public function getDiscord(): ?string + { + return $this->discord; + } + + /** + * @return string|null + */ + public function getYouTube(): ?string + { + return $this->youtube; + } +} diff --git a/src/Models/Version.php b/src/Models/Version.php new file mode 100644 index 0000000..a07dfb2 --- /dev/null +++ b/src/Models/Version.php @@ -0,0 +1,156 @@ +name = $version['name']; + $this->numeric = $version['numeric']; + $this->stage = $version['stage']; + + $this->ets2mpChecksum = new Checksum( + $version['ets2mp_checksum']['dll'], + $version['ets2mp_checksum']['adb'] + ); + + $this->atsmpChecksum = new Checksum( + $version['atsmp_checksum']['dll'], + $version['atsmp_checksum']['adb'] + ); + + $this->time = new Carbon($version['time'], 'UTC'); + $this->supportedETS2GameVersion = $version['supported_game_version']; + $this->supportedATSGameVersion = $version['supported_ats_game_version']; + } + + /** + * @return string + */ + public function getName(): string + { + return $this->name; + } + + /** + * @return string + */ + public function getNumeric(): string + { + return $this->numeric; + } + + /** + * @return string + */ + public function getStage(): string + { + return $this->stage; + } + + /** + * @return \TruckersMP\Models\Checksum + */ + public function getETS2MPChecksum() + { + return $this->ets2mpChecksum; + } + + /** + * @return \TruckersMP\Models\Checksum + */ + public function getATSMPChecksum() + { + return $this->atsmpChecksum; + } + + /** + * @return \Carbon\Carbon + */ + public function getTime(): Carbon + { + return $this->time; + } + + /** + * @return string + */ + public function getSupportedETS2GameVersion(): string + { + return $this->supportedETS2GameVersion; + } + + /** + * @return string + */ + public function getSupportedATSGameVersion(): string + { + return $this->supportedATSGameVersion; + } +} diff --git a/src/Requests/BanRequest.php b/src/Requests/BanRequest.php new file mode 100644 index 0000000..4f1a583 --- /dev/null +++ b/src/Requests/BanRequest.php @@ -0,0 +1,54 @@ +id = $id; + } + + /** + * Get the endpoint of the request. + * + * @return string + */ + public function getEndpoint(): string + { + return 'bans/' . $this->id; + } + + /** + * Get the data for the request. + * + * @return \TruckersMP\APIClient\Collections\BanCollection + * + * @throws \Http\Client\Exception + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + * @throws \Exception + */ + public function get(): BanCollection + { + return new BanCollection( + $this->send()['response'] + ); + } +} diff --git a/src/Requests/Company/MemberIndexRequest.php b/src/Requests/Company/MemberIndexRequest.php new file mode 100644 index 0000000..d98c6fb --- /dev/null +++ b/src/Requests/Company/MemberIndexRequest.php @@ -0,0 +1,54 @@ +companyId = $id; + } + + /** + * Get the endpoint of the request. + * + * @return string + */ + public function getEndpoint(): string + { + return 'vtc/' . $this->companyId . '/members'; + } + + /** + * Get the data for the request. + * + * @return CompanyMemberIndex + * + * @throws \Http\Client\Exception + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function get(): CompanyMemberIndex + { + return new CompanyMemberIndex( + $this->send()['response'] + ); + } +} diff --git a/src/Requests/Company/MemberRequest.php b/src/Requests/Company/MemberRequest.php new file mode 100644 index 0000000..1971e2c --- /dev/null +++ b/src/Requests/Company/MemberRequest.php @@ -0,0 +1,63 @@ +companyId = $companyId; + $this->memberId = $memberId; + } + + /** + * Get the endpoint of the request. + * + * @return string + */ + public function getEndpoint(): string + { + return 'vtc/' . $this->companyId . '/member/' . $this->memberId; + } + + /** + * Get the data for the request. + * + * @return mixed + * + * @throws \Http\Client\Exception + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function get(): CompanyMember + { + return new CompanyMember( + $this->send()['response'] + ); + } +} diff --git a/src/Requests/Company/PostIndexRequest.php b/src/Requests/Company/PostIndexRequest.php new file mode 100644 index 0000000..0ce2575 --- /dev/null +++ b/src/Requests/Company/PostIndexRequest.php @@ -0,0 +1,54 @@ +companyId = $companyId; + } + + /** + * Get the endpoint of the request. + * + * @return string + */ + public function getEndpoint(): string + { + return 'vtc/' . $this->companyId . '/news'; + } + + /** + * Get the data for the request. + * + * @return PostCollection|\TruckersMP\APIClient\Models\CompanyPost[] + * + * @throws \Http\Client\Exception + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function get(): PostCollection + { + return new PostCollection( + $this->send()['response'] + ); + } +} diff --git a/src/Requests/Company/PostRequest.php b/src/Requests/Company/PostRequest.php new file mode 100644 index 0000000..77dee44 --- /dev/null +++ b/src/Requests/Company/PostRequest.php @@ -0,0 +1,63 @@ +companyId = $companyId; + $this->postId = $postId; + } + + /** + * Get the endpoint of the request. + * + * @return string + */ + public function getEndpoint(): string + { + return 'vtc/' . $this->companyId . '/news/' . $this->postId; + } + + /** + * Get the data for the request. + * + * @return CompanyPost + * + * @throws \Http\Client\Exception + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function get(): CompanyPost + { + return new CompanyPost( + $this->send()['response'] + ); + } +} diff --git a/src/Requests/Company/RoleIndexRequest.php b/src/Requests/Company/RoleIndexRequest.php new file mode 100644 index 0000000..58aca74 --- /dev/null +++ b/src/Requests/Company/RoleIndexRequest.php @@ -0,0 +1,55 @@ +companyId = $companyId; + } + + /** + * Get the endpoint of the request. + * + * @return string + */ + public function getEndpoint(): string + { + return 'vtc/' . $this->companyId . '/roles'; + } + + /** + * Get the data for the request. + * + * @return \TruckersMP\APIClient\Collections\Company\RoleCollection + * + * @throws \Http\Client\Exception + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + * @throws \Exception + */ + public function get(): RoleCollection + { + return new RoleCollection( + $this->send()['response'] + ); + } +} diff --git a/src/Requests/Company/RoleRequest.php b/src/Requests/Company/RoleRequest.php new file mode 100644 index 0000000..4a7db0d --- /dev/null +++ b/src/Requests/Company/RoleRequest.php @@ -0,0 +1,63 @@ +companyId = $companyId; + $this->roleId = $roleId; + } + + /** + * Get the endpoint of the request. + * + * @return string + */ + public function getEndpoint(): string + { + return 'vtc/' . $this->companyId . '/role/' . $this->roleId; + } + + /** + * Get the data for the request. + * + * @return CompanyRole + * + * @throws \Http\Client\Exception + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function get(): CompanyRole + { + return new CompanyRole( + $this->send()['response'] + ); + } +} diff --git a/src/Requests/CompanyIndexRequest.php b/src/Requests/CompanyIndexRequest.php new file mode 100644 index 0000000..ea94bf6 --- /dev/null +++ b/src/Requests/CompanyIndexRequest.php @@ -0,0 +1,34 @@ +send()['response'] + ); + } +} diff --git a/src/Requests/CompanyRequest.php b/src/Requests/CompanyRequest.php new file mode 100644 index 0000000..9de6ba1 --- /dev/null +++ b/src/Requests/CompanyRequest.php @@ -0,0 +1,141 @@ +id = $id; + } + + /** + * Get the endpoint of the request. + * + * @return string + */ + public function getEndpoint(): string + { + return 'vtc/' . $this->id; + } + + /** + * Get the data for the request. + * + * @return Company + * + * @throws \Http\Client\Exception + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + * @throws \Exception + */ + public function get(): Company + { + return new Company( + $this->send()['response'] + ); + } + + /** + * Get the news posts for the company. + * + * @return \TruckersMP\APIClient\Requests\Company\PostIndexRequest + */ + public function posts(): PostIndexRequest + { + return new PostIndexRequest( + $this->id + ); + } + + /** + * Get the post for the company with the specified ID. + * + * @param int $id + * + * @return \TruckersMP\APIClient\Requests\Company\PostRequest + */ + public function post(int $id): PostRequest + { + return new PostRequest( + $this->id, + $id + ); + } + + /** + * Get the roles for the company. + * + * @return \TruckersMP\APIClient\Requests\Company\RoleIndexRequest + */ + public function roles(): RoleIndexRequest + { + return new RoleIndexRequest( + $this->id + ); + } + + /** + * Get the requested company role. + * + * @param int $id + * + * @return \TruckersMP\APIClient\Requests\Company\RoleRequest + */ + public function role(int $id): RoleRequest + { + return new RoleRequest( + $this->id, + $id + ); + } + + /** + * Get the members for the company. + * + * @return \TruckersMP\APIClient\Requests\Company\MemberIndexRequest + */ + public function members(): MemberIndexRequest + { + return new MemberIndexRequest( + $this->id + ); + } + + /** + * Get the requested company member. + * + * @param int $id + * + * @return \TruckersMP\APIClient\Requests\Company\MemberRequest + */ + public function member(int $id): MemberRequest + { + return new MemberRequest( + $this->id, + $id + ); + } +} diff --git a/src/Requests/GameTimeRequest.php b/src/Requests/GameTimeRequest.php new file mode 100644 index 0000000..daaee08 --- /dev/null +++ b/src/Requests/GameTimeRequest.php @@ -0,0 +1,34 @@ +send() + ); + } +} diff --git a/src/Requests/PlayerRequest.php b/src/Requests/PlayerRequest.php new file mode 100644 index 0000000..c49fc2a --- /dev/null +++ b/src/Requests/PlayerRequest.php @@ -0,0 +1,65 @@ +id = $id; + } + + /** + * Get the endpoint of the request. + * + * @return string + */ + public function getEndpoint(): string + { + return 'player/' . $this->id; + } + + /** + * Get the data for the request. + * + * @return Player + * + * @throws \Http\Client\Exception + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function get(): Player + { + return new Player( + $this->send()['response'] + ); + } + + /** + * Get the players bans. + * + * @return \TruckersMP\APIClient\Requests\BanRequest + */ + public function bans(): BanRequest + { + return new BanRequest( + $this->id + ); + } +} diff --git a/src/Requests/Request.php b/src/Requests/Request.php new file mode 100644 index 0000000..ab13868 --- /dev/null +++ b/src/Requests/Request.php @@ -0,0 +1,88 @@ +message = new GuzzleMessageFactory(); + $this->adapter = new GuzzleAdapter( + new GuzzleClient(Client::config()) + ); + + $this->url = 'https://' . self::API_ENDPOINT . '/' . self::API_VERSION . '/'; + } + + /** + * Get the endpoint of the request. + * + * @return string + */ + abstract public function getEndpoint(): string; + + /** + * Get the data for the request. + * + * @return mixed + */ + abstract public function get(); + + /** + * Send the request to the API endpoint and get the result. + * + * @return array + * + * @throws \Http\Client\Exception + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function send(): array + { + $request = $this->message->createRequest('GET', $this->url . $this->getEndpoint()); + $result = null; + + try { + $result = $this->adapter->sendRequest($request); + } catch (HttpException $exception) { + ApiErrorHandler::check($exception->getResponse()->getBody(), $exception->getCode()); + } + + return json_decode((string) $result->getBody(), true, 512, JSON_BIGINT_AS_STRING); + } +} diff --git a/src/Requests/RuleRequest.php b/src/Requests/RuleRequest.php new file mode 100644 index 0000000..25a9f9c --- /dev/null +++ b/src/Requests/RuleRequest.php @@ -0,0 +1,34 @@ +send() + ); + } +} diff --git a/src/Requests/ServerRequest.php b/src/Requests/ServerRequest.php new file mode 100644 index 0000000..845c1a0 --- /dev/null +++ b/src/Requests/ServerRequest.php @@ -0,0 +1,34 @@ +send()['response'] + ); + } +} diff --git a/src/Requests/VersionRequest.php b/src/Requests/VersionRequest.php new file mode 100644 index 0000000..642f8f9 --- /dev/null +++ b/src/Requests/VersionRequest.php @@ -0,0 +1,35 @@ +send() + ); + } +} diff --git a/src/Types/Ban.php b/src/Types/Ban.php deleted file mode 100644 index 030084a..0000000 --- a/src/Types/Ban.php +++ /dev/null @@ -1,80 +0,0 @@ -expires = null; - } else { - $this->expires = new Carbon($ban['expiration'], 'UTC'); - } - - // Time Added - $this->created = new Carbon($ban['timeAdded'], 'UTC'); - - // Active - $this->active = $ban['active']; - if (!is_null($this->expires) && $this->active) { - if (!$this->expires->greaterThan(Carbon::now('UTC'))) { - $this->active = false; - } - } - - $this->reason = $ban['reason']; - $this->adminName = $ban['adminName']; - $this->adminID = $ban['adminID']; - } -} diff --git a/src/Types/Bans.php b/src/Types/Bans.php deleted file mode 100644 index 0be4a6d..0000000 --- a/src/Types/Bans.php +++ /dev/null @@ -1,121 +0,0 @@ -position = 0; - - if ($response['error'] && - ($response['descriptor'] === 'No player ID submitted' || - $response['descriptor'] === 'Invalid user ID') - ) { - throw new PlayerNotFoundException($response['descriptor']); - } - - foreach ($response['response'] as $k => $ban) { - $this->bans[$k] = new Ban($ban); - } - } - - public function rewind() - { - $this->position = 0; - } - - /** - * @return mixed - */ - public function current() - { - return $this->bans[$this->position]; - } - - /** - * @return int - */ - public function key() - { - return $this->position; - } - - 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 deleted file mode 100644 index 24bc2ce..0000000 --- a/src/Types/GameTime.php +++ /dev/null @@ -1,46 +0,0 @@ -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 deleted file mode 100644 index 8fd8905..0000000 --- a/src/Types/Player.php +++ /dev/null @@ -1,87 +0,0 @@ -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 deleted file mode 100644 index b2e0d97..0000000 --- a/src/Types/Server.php +++ /dev/null @@ -1,143 +0,0 @@ -id = intval($server['id']); - $this->game = $server['game']; - $this->ip = $server['ip']; - $this->port = intval($server['port']); - $this->name = $server['name']; - $this->shortName = $server['shortname']; - $this->online = boolval($server['online']); - $this->players = intval($server['players']); - $this->queue = intval($server['queue']); - $this->maxPlayers = intval($server['maxplayers']); - $this->speedLimiter = boolval($server['speedlimiter']); - $this->collisions = boolval($server['collisions']); - $this->carsForPlayers = boolval($server['carsforplayers']); - $this->policeCarsForPlayers = boolval($server['policecarsforplayers']); - $this->afkEnabled = boolval($server['afkenabled']); - $this->syncDelay = intval($server['syncdelay']); - } -} diff --git a/src/Types/Servers.php b/src/Types/Servers.php deleted file mode 100644 index acf563b..0000000 --- a/src/Types/Servers.php +++ /dev/null @@ -1,89 +0,0 @@ -position = 0; - - if ($response['error'] === 'true' && $response['descriptor'] === 'Unable to fetch servers') { - throw new APIErrorException($response['descriptor']); - } - - foreach ($response['response'] as $k => $server) { - $this->servers[$k] = new Server($server); - } - } - - public function rewind() - { - $this->position = 0; - } - - public function current() - { - return $this->servers[$this->position]; - } - - public function key() - { - return $this->position; - } - - public function next() - { - $this->position++; - } - - public function valid() - { - return isset($this->servers[$this->position]); - } - - public function offsetSet($offset, $value) - { - // TODO: custom class that gives a better description of the error - return new \Exception('Can not change servers'); - } - - public function offsetExists($offset) - { - return isset($this->servers[$offset]); - } - - public function offsetUnset($offset) - { - // TODO: custom class that gives a better description of the error - return new \Exception('Can not change servers'); - } - - public function offsetGet($offset) - { - return isset($this->servers[$offset]) ? $this->servers[$offset] : null; - } -} diff --git a/src/Types/Version.php b/src/Types/Version.php deleted file mode 100644 index 0ba32bf..0000000 --- a/src/Types/Version.php +++ /dev/null @@ -1,50 +0,0 @@ -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']; - } -} diff --git a/tests/TestCase.php b/tests/TestCase.php new file mode 100644 index 0000000..bae51dc --- /dev/null +++ b/tests/TestCase.php @@ -0,0 +1,428 @@ +client = new Client(); + + CacheManager::setDefaultConfig(new ConfigurationOption([ + 'path' => __DIR__ . '/cache', + ])); + + $this->cache = CacheManager::getInstance(); + } + + /** + * Get or cache the given player. + * + * @param int $id + * + * @return \TruckersMP\APIClient\Models\Player + * + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function player(int $id): Player + { + $cachedPlayer = $this->cache->getItem('player_' . $id); + + if (!$cachedPlayer->isHit()) { + $cachedPlayer->set($this->client->player($id)->get())->expiresAfter(self::CACHE_SECONDS); + $this->cache->save($cachedPlayer); + } + + return $cachedPlayer->get(); + } + + /** + * Get or cache the players bans. + * + * @param int $id + * + * @return \TruckersMP\APIClient\Collections\BanCollection|\TruckersMP\APIClient\Models\Ban[] + * + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function playerBans(int $id): BanCollection + { + $cachedBans = $this->cache->getItem('player_bans_' . $id); + + if (!$cachedBans->isHit()) { + $cachedBans->set($this->client->player($id)->bans()->get())->expiresAfter(self::CACHE_SECONDS); + $this->cache->save($cachedBans); + } + + return $cachedBans->get(); + } + + /** + * Get or cache the bans for the player. + * + * @param int $id + * + * @return \TruckersMP\APIClient\Collections\BanCollection + * + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function bans(int $id): BanCollection + { + $cachedBans = $this->cache->getItem('bans_' . $id); + + if (!$cachedBans->isHit()) { + $cachedBans->set($this->client->bans($id)->get())->expiresAfter(self::CACHE_SECONDS); + $this->cache->save($cachedBans); + } + + return $cachedBans->get(); + } + + /** + * Get or cache the server request. + * + * @return \TruckersMP\APIClient\Collections\ServerCollection|\TruckersMP\APIClient\Models\Server[] + * + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function servers(): ServerCollection + { + $cachedServers = $this->cache->getItem('servers'); + + if (!$cachedServers->isHit()) { + $cachedServers->set($this->client->servers()->get())->expiresAfter(self::CACHE_SECONDS); + $this->cache->save($cachedServers); + } + + return $cachedServers->get(); + } + + /** + * Get or cache the game time. + * + * @return \TruckersMP\APIClient\Models\GameTime + * + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function gameTime(): GameTime + { + $cachedGameTime = $this->cache->getItem('game_time'); + + if (!$cachedGameTime->isHit()) { + $cachedGameTime->set($this->client->gameTime()->get())->expiresAfter(self::CACHE_SECONDS); + $this->cache->save($cachedGameTime); + } + + return $cachedGameTime->get(); + } + + /** + * Get or cache the recent companies. + * + * @return \TruckersMP\APIClient\Models\CompanyIndex + * + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function companies(): CompanyIndex + { + $cachedCompanies = $this->cache->getItem('recent_companies'); + + if (!$cachedCompanies->isHit()) { + $cachedCompanies->set($this->client->companies()->get()); + $this->cache->save($cachedCompanies); + } + + return $cachedCompanies->get(); + } + + /** + * Get or cache the company with the specified id. + * + * @param int $id + * + * @return \TruckersMP\APIClient\Models\Company + * + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function company(int $id): Company + { + $cachedCompany = $this->cache->getItem('company_' . $id); + + if (!$cachedCompany->isHit()) { + $cachedCompany->set($this->client->company($id)->get())->expiresAfter(self::CACHE_SECONDS); + $this->cache->save($cachedCompany); + } + + return $cachedCompany->get(); + } + + /** + * Get the news posts for the specified company. + * + * @param int $id + * + * @return PostCollection|\TruckersMP\APIClient\Models\CompanyPost[] + * + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function companyPosts(int $id): PostCollection + { + $cachedNews = $this->cache->getItem('company_posts_' . $id); + + if (!$cachedNews->isHit()) { + $cachedNews->set($this->client->company($id)->posts()->get())->expiresAfter(self::CACHE_SECONDS); + $this->cache->save($cachedNews); + } + + return $cachedNews->get(); + } + + /** + * Get or Cache the specified company post. + * + * @param int $companyId + * @param int $postId + * + * @return CompanyPost + * + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function companyPost(int $companyId, int $postId): CompanyPost + { + $cachedPost = $this->cache->getItem('company_' . $companyId . '_post_' . $postId); + + if (!$cachedPost->isHit()) { + $cachedPost->set( + $this->client->company($companyId)->post($postId)->get() + )->expiresAfter(self::CACHE_SECONDS); + + $this->cache->save($cachedPost); + } + + return $cachedPost->get(); + } + + /** + * Get or cache the company roles. + * + * @param int $companyId + * + * @return \TruckersMP\APIClient\Collections\Company\RoleCollection|CompanyRole[] + * + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function companyRoles(int $companyId): RoleCollection + { + $cachedRoles = $this->cache->getItem('company_roles_' . $companyId); + + if (!$cachedRoles->isHit()) { + $cachedRoles->set($this->client->company($companyId)->roles()->get())->expiresAfter(self::CACHE_SECONDS); + $this->cache->save($cachedRoles); + } + + return $cachedRoles->get(); + } + + /** + * Get or cache the company role. + * + * @param int $companyId + * @param int $roleId + * + * @return \TruckersMP\APIClient\Models\CompanyRole + * + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function companyRole(int $companyId, int $roleId): CompanyRole + { + $cachedRole = $this->cache->getItem('company_' . $companyId . '_roles_' . $roleId); + + if (!$cachedRole->isHit()) { + $cachedRole->set( + $this->client->company($companyId)->role($roleId)->get() + )->expiresAfter(self::CACHE_SECONDS); + + $this->cache->save($cachedRole); + } + + return $cachedRole->get(); + } + + /** + * Get or cache the company members. + * + * @param int $companyId + * + * @return mixed + * + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function companyMembers(int $companyId): CompanyMemberIndex + { + $cachedMembers = $this->cache->getItem('company_members_' . $companyId); + + if (!$cachedMembers->isHit()) { + $cachedMembers->set( + $this->client->company($companyId)->members()->get() + ); + + $this->cache->save($cachedMembers); + } + + return $cachedMembers->get(); + } + + /** + * Get or cache the company member. + * + * @param int $companyId + * @param int $memberId + * + * @return \TruckersMP\APIClient\Models\CompanyMember + * + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function companyMember(int $companyId, int $memberId): CompanyMember + { + $cachedMember = $this->cache->getItem('company_member_' . $memberId); + + if (!$cachedMember->isHit()) { + $cachedMember->set( + $this->client->company($companyId)->member($memberId)->get() + )->expiresAfter(self::CACHE_SECONDS); + + $this->cache->save($cachedMember); + } + + return $cachedMember->get(); + } + + /** + * Get or cache the TruckersMP version. + * + * @return \TruckersMP\APIClient\Models\Version + * + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function version(): Version + { + $cachedVersion = $this->cache->getItem('version'); + + if (!$cachedVersion->isHit()) { + $cachedVersion->set($this->client->version()->get())->expiresAfter(self::CACHE_SECONDS); + $this->cache->save($cachedVersion); + } + + return $cachedVersion->get(); + } + + /** + * Get or cache the rules. + * + * @return \TruckersMP\APIClient\Models\Rule + * + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function rules(): Rule + { + $cachedRules = $this->cache->getItem('rules'); + + if (!$cachedRules->isHit()) { + $cachedRules->set($this->client->rules()->get())->expiresAfter(self::CACHE_SECONDS); + $this->cache->save($cachedRules); + } + + return $cachedRules->get(); + } +} diff --git a/tests/Unit/BanTest.php b/tests/Unit/BanTest.php new file mode 100644 index 0000000..5151d24 --- /dev/null +++ b/tests/Unit/BanTest.php @@ -0,0 +1,151 @@ +bans(self::TEST_ACCOUNT); + + $this->assertInstanceOf(BanCollection::class, $bans); + + if (count($bans) > 0) { + $this->assertInstanceOf(Ban::class, $bans[0]); + } + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasAnExpiryDate() + { + $bans = $this->bans(self::TEST_ACCOUNT); + + if (count($bans) > 0) { + $ban = $bans[0]; + + if ($ban->getExpirationDate() !== null) { + $this->assertInstanceOf(Carbon::class, $ban->getExpirationDate()); + } else { + $this->assertNull($ban->getExpirationDate()); + } + } else { + $this->assertCount(0, $bans); + } + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasACreatedDate() + { + $bans = $this->bans(self::TEST_ACCOUNT); + + if (count($bans) > 0) { + $ban = $bans[0]; + + $this->assertInstanceOf(Carbon::class, $ban->getCreatedAt()); + } else { + $this->assertCount(0, $bans); + } + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasAnActiveState() + { + $bans = $this->bans(self::TEST_ACCOUNT); + + if (count($bans) > 0) { + $ban = $bans[0]; + + $this->assertIsBool($ban->isActive()); + } else { + $this->assertCount(0, $bans); + } + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasAReason() + { + $bans = $this->bans(self::TEST_ACCOUNT); + + if (count($bans) > 0) { + $ban = $bans[0]; + + $this->assertIsString($ban->getReason()); + } else { + $this->assertCount(0, $bans); + } + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasTheNameOfTheAdmin() + { + $bans = $this->bans(self::TEST_ACCOUNT); + + if (count($bans) > 0) { + $ban = $bans[0]; + + $this->assertIsString($ban->getAdminName()); + } else { + $this->assertCount(0, $bans); + } + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasTheIdOfTheAdmin() + { + $bans = $this->bans(self::TEST_ACCOUNT); + + if (count($bans) > 0) { + $ban = $bans[0]; + + $this->assertIsInt($ban->getAdminId()); + } else { + $this->assertCount(0, $bans); + } + } +} diff --git a/tests/Unit/ChecksumTest.php b/tests/Unit/ChecksumTest.php new file mode 100644 index 0000000..5e7907e --- /dev/null +++ b/tests/Unit/ChecksumTest.php @@ -0,0 +1,34 @@ +version(); + + $this->assertIsString($version->getATSMPChecksum()->getDLL()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasAnADB() + { + $version = $this->version(); + + $this->assertIsString($version->getATSMPChecksum()->getADB()); + } +} diff --git a/tests/Unit/CompanyMemberTest.php b/tests/Unit/CompanyMemberTest.php new file mode 100644 index 0000000..14730c7 --- /dev/null +++ b/tests/Unit/CompanyMemberTest.php @@ -0,0 +1,149 @@ +companyMembers(self::TEST_COMPANY); + + $this->assertInstanceOf(CompanyMemberIndex::class, $members); + + $this->assertInstanceOf(MemberCollection::class, $members->getMembers()); + $this->assertIsInt($members->getCount()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testWeCanGetAMember() + { + $member = $this->companyMember(self::TEST_COMPANY, self::TEST_MEMBER); + + $this->assertInstanceOf(CompanyMember::class, $member); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testTheMemberHasAnId() + { + $member = $this->companyMember(self::TEST_COMPANY, self::TEST_MEMBER); + + $this->assertNotEmpty($member->getId()); + $this->assertIsInt($member->getId()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testTheMemberHasAUserId() + { + $member = $this->companyMember(self::TEST_COMPANY, self::TEST_MEMBER); + + $this->assertNotEmpty($member->getUserId()); + $this->assertIsInt($member->getUserId()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testTheMemberHasAUsername() + { + $member = $this->companyMember(self::TEST_COMPANY, self::TEST_MEMBER); + + $this->assertNotEmpty($member->getUsername()); + $this->assertIsString($member->getUsername()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testTheMemberHasASteamId() + { + $member = $this->companyMember(self::TEST_COMPANY, self::TEST_MEMBER); + + $this->assertNotEmpty($member->getSteamId()); + $this->assertIsString($member->getSteamId()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testTheMemberHasARoleId() + { + $member = $this->companyMember(self::TEST_COMPANY, self::TEST_MEMBER); + + $this->assertNotEmpty($member->getRoleId()); + $this->assertIsInt($member->getRoleId()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testTheMemberHasARole() + { + $member = $this->companyMember(self::TEST_COMPANY, self::TEST_MEMBER); + + $this->assertNotEmpty($member->getRole()); + $this->assertIsString($member->getRole()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testTheMemberHasAJoinDate() + { + $member = $this->companyMember(self::TEST_COMPANY, self::TEST_MEMBER); + + $this->assertNotEmpty($member->getJoinDate()); + $this->assertInstanceOf(Carbon::class, $member->getJoinDate()); + } +} diff --git a/tests/Unit/CompanyPostTest.php b/tests/Unit/CompanyPostTest.php new file mode 100644 index 0000000..ac305e7 --- /dev/null +++ b/tests/Unit/CompanyPostTest.php @@ -0,0 +1,143 @@ +companyPosts(self::TEST_COMPANY); + + $this->assertInstanceOf(PostCollection::class, $posts); + + if ($posts->count() > 0) { + $post = $posts[0]; + + $this->assertInstanceOf(CompanyPost::class, $post); + } + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testWeCanGetAPost() + { + $post = $this->companyPost(self::TEST_COMPANY, self::TEST_POST); + + $this->assertInstanceOf(CompanyPost::class, $post); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasAnId() + { + $post = $this->companyPost(self::TEST_COMPANY, self::TEST_POST); + + $this->assertIsInt($post->getId()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasATitle() + { + $post = $this->companyPost(self::TEST_COMPANY, self::TEST_POST); + + $this->assertIsString($post->getTitle()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasASummary() + { + $post = $this->companyPost(self::TEST_COMPANY, self::TEST_POST); + + $this->assertIsString($post->getSummary()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasCotent() + { + $post = $this->companyPost(self::TEST_COMPANY, self::TEST_POST); + + $this->assertIsString($post->getContent()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasAnAuthorId() + { + $post = $this->companyPost(self::TEST_COMPANY, self::TEST_POST); + + $this->assertIsInt($post->getAuthorId()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasAnAuthor() + { + $post = $this->companyPost(self::TEST_COMPANY, self::TEST_POST); + + $this->assertIsString($post->getAuthor()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testIfThePostIsPinned() + { + $post = $this->companyPost(self::TEST_COMPANY, self::TEST_POST); + + $this->assertIsBool($post->isPinned()); + } +} diff --git a/tests/Unit/CompanyRoleTest.php b/tests/Unit/CompanyRoleTest.php new file mode 100644 index 0000000..df32cf0 --- /dev/null +++ b/tests/Unit/CompanyRoleTest.php @@ -0,0 +1,131 @@ +companyRoles(self::TEST_COMPANY); + + $this->assertInstanceOf(RoleCollection::class, $roles); + + if ($roles->count() > 0) { + $role = $roles[0]; + + $this->assertInstanceOf(CompanyRole::class, $role); + } + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testWeCanGetARole() + { + $role = $this->companyRole(self::TEST_COMPANY, self::TEST_ROLE); + + $this->assertInstanceOf(CompanyRole::class, $role); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasAnId() + { + $role = $this->companyRole(self::TEST_COMPANY, self::TEST_ROLE); + + $this->assertIsInt($role->getId()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasAName() + { + $role = $this->companyRole(self::TEST_COMPANY, self::TEST_ROLE); + + $this->assertIsString($role->getName()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasAnOrder() + { + $role = $this->companyRole(self::TEST_COMPANY, self::TEST_ROLE); + + $this->assertIsInt($role->getOrder()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testIfItIsAnOwner() + { + $role = $this->companyRole(self::TEST_COMPANY, self::TEST_ROLE); + + $this->assertIsBool($role->isOwner()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasACreatedAtDate() + { + $role = $this->companyRole(self::TEST_COMPANY, self::TEST_ROLE); + + $this->assertInstanceOf(Carbon::class, $role->getCreatedAt()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasAnUpdatedAtDate() + { + $role = $this->companyRole(self::TEST_COMPANY, self::TEST_ROLE); + + $this->assertInstanceOf(Carbon::class, $role->getUpdatedAt()); + } +} diff --git a/tests/Unit/CompanyTest.php b/tests/Unit/CompanyTest.php new file mode 100644 index 0000000..afa3f3d --- /dev/null +++ b/tests/Unit/CompanyTest.php @@ -0,0 +1,373 @@ +companies(); + + $this->assertInstanceOf(CompanyIndex::class, $companies); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testWeCanGetTheRecentCompanies() + { + $companies = $this->companies()->getRecent(); + + $this->assertNotEmpty($companies); + + $this->assertInstanceOf(CompanyCollection::class, $companies); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testWeCanGetTheFeaturedCompanies() + { + $companies = $this->companies()->getFeatured(); + + $this->assertNotEmpty($companies); + + $this->assertInstanceOf(CompanyCollection::class, $companies); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testWeCanGetTheFeaturedCoverCompanies() + { + $companies = $this->companies()->getFeaturedCovered(); + + $this->assertNotEmpty($companies); + + $this->assertInstanceOf(CompanyCollection::class, $companies); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testWeCanGetACompany() + { + $company = $this->company(self::TEST_COMPANY); + + $this->assertInstanceOf(Company::class, $company); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasAnId() + { + $company = $this->company(self::TEST_COMPANY); + + $this->assertIsInt($company->getId()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasAName() + { + $company = $this->company(self::TEST_COMPANY); + + $this->assertIsString($company->getName()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasAnOwnerId() + { + $company = $this->company(self::TEST_COMPANY); + + $this->assertIsInt($company->getOwnerId()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasAnOwnerName() + { + $company = $this->company(self::TEST_COMPANY); + + $this->assertIsString($company->getOwnerName()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasASlogan() + { + $company = $this->company(self::TEST_COMPANY); + + $this->assertIsString($company->getSlogan()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasATag() + { + $company = $this->company(self::TEST_COMPANY); + + $this->assertIsString($company->getTag()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasALogo() + { + $company = $this->company(self::TEST_COMPANY); + + $this->assertIsString($company->getLogo()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasACover() + { + $company = $this->company(self::TEST_COMPANY); + + $this->assertIsString($company->getCover()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasInformation() + { + $company = $this->company(self::TEST_COMPANY); + + $this->assertIsString($company->getInformation()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasRules() + { + $company = $this->company(self::TEST_COMPANY); + + $this->assertIsString($company->getRules()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasRequirements() + { + $company = $this->company(self::TEST_COMPANY); + + $this->assertIsString($company->getRequirements()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasAWebsite() + { + $company = $this->company(self::TEST_COMPANY); + + $this->assertIsString($company->getWebsite()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasSocialInformation() + { + $company = $this->company(self::TEST_COMPANY); + + $this->assertInstanceOf(Social::class, $company->getSocial()); + + // Twitter + if ($company->getSocial()->getTwitter() !== null) { + $this->assertIsString($company->getSocial()->getTwitter()); + } + + // Facebook + if ($company->getSocial()->getFacebook() !== null) { + $this->assertIsString($company->getSocial()->getFacebook()); + } + + // Twitch + if ($company->getSocial()->getTwitch() !== null) { + $this->assertIsString($company->getSocial()->getTwitch()); + } + + // PlaysTV + if ($company->getSocial()->getPlays() !== null) { + $this->assertIsString($company->getSocial()->getPlays()); + } + + // Discord + if ($company->getSocial()->getDiscord() !== null) { + $this->assertIsString($company->getSocial()->getDiscord()); + } + + // YouTube + if ($company->getSocial()->getYouTube() !== null) { + $this->assertIsString($company->getSocial()->getYouTube()); + } + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasSupportedGames() + { + $company = $this->company(self::TEST_COMPANY); + + $this->assertInstanceOf(Game::class, $company->getGames()); + + $this->assertIsBool($company->getGames()->isAts()); + $this->assertIsBool($company->getGames()->isEts()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasMemberCount() + { + $company = $this->company(self::TEST_COMPANY); + + $this->assertIsInt($company->getMembersCount()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasARecruitmentState() + { + $company = $this->company(self::TEST_COMPANY); + + $this->assertIsString($company->getRecruitment()); + + $this->assertIsBool($company->isRecruitmentClosed()); + $this->assertIsBool($company->isRecruitmentOpen()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasALanguage() + { + $company = $this->company(self::TEST_COMPANY); + + $this->assertIsString($company->getLanguage()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testIfItsVerified() + { + $company = $this->company(self::TEST_COMPANY); + + $this->assertIsBool($company->isVerified()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasACreatedDate() + { + $company = $this->company(self::TEST_COMPANY); + + $this->assertInstanceOf(Carbon::class, $company->getCreatedDate()); + } +} diff --git a/tests/Unit/GameTimeTest.php b/tests/Unit/GameTimeTest.php new file mode 100644 index 0000000..68c7170 --- /dev/null +++ b/tests/Unit/GameTimeTest.php @@ -0,0 +1,24 @@ +gameTime(); + + $this->assertInstanceOf(GameTime::class, $time); + $this->assertInstanceOf(Carbon::class, $time->getTime()); + } +} diff --git a/tests/Unit/PlayerTest.php b/tests/Unit/PlayerTest.php new file mode 100644 index 0000000..b8a56e2 --- /dev/null +++ b/tests/Unit/PlayerTest.php @@ -0,0 +1,312 @@ +player(self::TEST_ACCOUNT); + + $this->assertInstanceOf(Player::class, $player); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasAnId() + { + $player = $this->player(self::TEST_ACCOUNT); + + $this->assertIsInt($player->getId()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasAName() + { + $player = $this->player(self::TEST_ACCOUNT); + + $this->assertIsString($player->getName()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasAnAvatar() + { + $player = $this->player(self::TEST_ACCOUNT); + + $this->assertIsString($player->getAvatar()); + + if ($player->getSmallAvatar() !== null) { + $this->assertIsString($player->getSmallAvatar()); + } + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasAJoinDate() + { + $player = $this->player(self::TEST_ACCOUNT); + + $this->assertInstanceOf(Carbon::class, $player->getJoinDate()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasASteamId() + { + $player = $this->player(self::TEST_ACCOUNT); + + $this->assertIsString($player->getSteamID64()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasAGroupName() + { + $player = $this->player(self::TEST_ACCOUNT); + + $this->assertIsString($player->getGroupName()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasAGroupId() + { + $player = $this->player(self::TEST_ACCOUNT); + + $this->assertIsInt($player->getGroupId()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testIfItIsBanned() + { + $player = $this->player(self::TEST_ACCOUNT); + + $this->assertIsBool($player->isBanned()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasABannedUntilDate() + { + $player = $this->player(self::TEST_ACCOUNT); + + $this->assertInstanceOf(Carbon::class, $player->getBannedUntilDate()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testIfBansAreHidden() + { + $player = $this->player(self::TEST_ACCOUNT); + + $this->assertIsBool($player->hasBansHidden()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasIfAdmin() + { + $player = $this->player(self::TEST_ACCOUNT); + + $this->assertIsBool($player->isAdmin()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasACompanyId() + { + $player = $this->player(self::TEST_ACCOUNT); + + $this->assertIsInt($player->getCompanyId()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasACompanyName() + { + $player = $this->player(self::TEST_ACCOUNT); + + $this->assertIsString($player->getCompanyName()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasACompanyTag() + { + $player = $this->player(self::TEST_ACCOUNT); + + $this->assertIsString($player->getCompanyTag()); + } + + public function testIfInACompany() + { + $player = $this->player(self::TEST_ACCOUNT); + + $this->assertIsBool($player->isInCompany()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasAMemberId() + { + $player = $this->player(self::TEST_ACCOUNT); + + $this->assertIsInt($player->getCompanyMemberId()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testWeCanGetThePlayersBans() + { + $bans = $this->playerBans(self::TEST_ACCOUNT); + + $this->assertInstanceOf(BanCollection::class, $bans); + + $player = $this->player(self::TEST_ACCOUNT); + + $this->assertInstanceOf(BanCollection::class, $player->getBans()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testWeCanGetThePlayersCompany() + { + $player = $this->player(self::TEST_ACCOUNT); + + $company = $player->getCompany(); + + if ($player->isInCompany()) { + $this->assertInstanceOf(Company::class, $company); + } else { + $this->assertNull($company); + } + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testWeCanGetThePlayersCompanyMember() + { + $player = $this->player(self::TEST_ACCOUNT); + + $member = $player->getCompanyMember(); + + if ($player->isInCompany()) { + $this->assertInstanceOf(CompanyMember::class, $member); + } else { + $this->assertNull($member); + } + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testWeCanGetThePlayersCompanyRole() + { + $player = $this->player(self::TEST_ACCOUNT); + + $role = $player->getCompanyRole(); + + if ($player->isInCompany()) { + $this->assertInstanceOf(CompanyRole::class, $role); + } else { + $this->assertNull($role); + } + } +} diff --git a/tests/Unit/RuleTest.php b/tests/Unit/RuleTest.php new file mode 100644 index 0000000..2e5f6c2 --- /dev/null +++ b/tests/Unit/RuleTest.php @@ -0,0 +1,48 @@ +rules(); + + $this->assertInstanceOf(Rule::class, $rules); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasTheRules() + { + $rules = $this->rules(); + + $this->assertIsString($rules->getRules()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasTheRevision() + { + $rules = $this->rules(); + + $this->assertIsInt($rules->getRevision()); + } +} diff --git a/tests/Unit/ServerTest.php b/tests/Unit/ServerTest.php new file mode 100644 index 0000000..0bd6154 --- /dev/null +++ b/tests/Unit/ServerTest.php @@ -0,0 +1,304 @@ +servers(); + + $this->assertInstanceOf(ServerCollection::class, $servers); + + if ($servers->count() > 0) { + $this->assertInstanceOf(Server::class, $servers[0]); + } + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasAnId() + { + $server = $this->servers()[0]; + + $this->assertIsInt($server->getId()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasAGame() + { + $server = $this->servers()[0]; + + $this->assertIsString($server->getGame()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasAnIp() + { + $server = $this->servers()[0]; + + $this->assertIsString($server->getIp()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasAPort() + { + $server = $this->servers()[0]; + + $this->assertIsInt($server->getPort()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasAName() + { + $server = $this->servers()[0]; + + $this->assertIsString($server->getName()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasAShortName() + { + $server = $this->servers()[0]; + + $this->assertIsString($server->getShortName()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasAnIdPrefix() + { + $server = $this->servers()[0]; + + if ($server->getIdPrefix() !== null) { + $this->assertIsString($server->getIdPrefix()); + } else { + $this->assertNull($server->getIdPrefix()); + } + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasAnOnlineState() + { + $server = $this->servers()[0]; + + $this->assertIsBool($server->isOnline()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasPlayers() + { + $server = $this->servers()[0]; + + $this->assertIsInt($server->getPlayers()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasAQueue() + { + $server = $this->servers()[0]; + + $this->assertIsInt($server->getQueue()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasMaxPlayers() + { + $server = $this->servers()[0]; + + $this->assertIsInt($server->getMaxPlayers()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasADisplayOrder() + { + $server = $this->servers()[0]; + + $this->assertIsInt($server->getDisplayOrder()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasASpeedLimit() + { + $server = $this->servers()[0]; + + $this->assertIsBool($server->hasSpeedLimit()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasCollisions() + { + $server = $this->servers()[0]; + + $this->assertIsBool($server->hasCollisions()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasCarsForPlayers() + { + $server = $this->servers()[0]; + + $this->assertIsBool($server->canPlayersHaveCars()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasPoliceCarsForPlayers() + { + $server = $this->servers()[0]; + + $this->assertIsBool($server->canPlayersHavePoliceCars()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasAfkEnable() + { + $server = $this->servers()[0]; + + $this->assertIsBool($server->isAfkEnabled()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasAnEvent() + { + $server = $this->servers()[0]; + + $this->assertIsBool($server->isEvent()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasASpecialEvent() + { + $server = $this->servers()[0]; + + $this->assertIsBool($server->isSpecialEvent()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasPromods() + { + $server = $this->servers()[0]; + + $this->assertIsBool($server->hasPromods()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasSyncDelay() + { + $server = $this->servers()[0]; + + $this->assertIsInt($server->getSyncDelay()); + } +} diff --git a/tests/Unit/VersionTest.php b/tests/Unit/VersionTest.php new file mode 100644 index 0000000..e80a254 --- /dev/null +++ b/tests/Unit/VersionTest.php @@ -0,0 +1,128 @@ +version(); + + $this->assertInstanceOf(Version::class, $version); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasAName() + { + $version = $this->version(); + + $this->assertIsString($version->getName()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasANumeric() + { + $version = $this->version(); + + $this->assertIsString($version->getNumeric()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasAStage() + { + $version = $this->version(); + + $this->assertIsString($version->getStage()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasAnETS2MPChecksum() + { + $version = $this->version(); + + $this->assertInstanceOf(Checksum::class, $version->getETS2MPChecksum()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasAnATSMPChecksum() + { + $version = $this->version(); + + $this->assertInstanceOf(Checksum::class, $version->getATSMPChecksum()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasATime() + { + $version = $this->version(); + + $this->assertInstanceOf(Carbon::class, $version->getTime()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasASupportedGameVersion() + { + $version = $this->version(); + + $this->assertIsString($version->getSupportedETS2GameVersion()); + } + + /** + * @throws \Http\Client\Exception + * @throws \Phpfastcache\Exceptions\PhpfastcacheInvalidArgumentException + * @throws \TruckersMP\APIClient\Exceptions\PageNotFoundException + * @throws \TruckersMP\APIClient\Exceptions\RequestException + */ + public function testItHasASupportedATSGameVersion() + { + $version = $this->version(); + + $this->assertIsString($version->getSupportedATSGameVersion()); + } +}