velkuns / artifactsmmo-client
PHP Client for Artifacts MMO Game Code
Requires
- php: 8.1.*||8.2.*||8.3.*
- ext-json: *
- eureka/component-serializer: ^2.1
- psr/http-client: ^1.0
- psr/http-factory: ^1.0
- psr/http-message: ^1.0||^2.0
- psr/log: ^1.1||^2.0||^3.0
Requires (Dev)
- cebe/php-openapi: ^1.7.0
- eureka/component-console: ^6.2.0
- eureka/component-curl: ^3.0.0
- friendsofphp/php-cs-fixer: ^3.62.0
- lcobucci/clock: ^3.0.0
- maglnet/composer-require-checker: ^4.7.1
- nikic/php-parser: ^4.19.1
- nyholm/psr7: ^1.8.1
- phpstan/phpstan: ^1.11.11
- phpstan/phpstan-phpunit: ^1.4.0
- phpunit/phpcov: ^9.0.2
- phpunit/phpunit: ^10.5.30
- shipmonk/composer-dependency-analyser: ^1.7.0
README
Why?
This SDK / Client is a wrapper to call Artifacts MMO API. Each clients methods call and endpoint and return a Value Object as defined in OpenAPI Spec from Artifacts MMO API.
Artifacts MMO API Doc: https://api.artifactsmmo.com/docs/
When POST endpoint need a BODY, an Body* Value Object (VO) is required to call the endpoint. If any query param is available, you can also pass it to the endpoint (PHP doc is set for params with name in this case)
Installation
If you wish to install it in your project, require it via composer:
composer require velkuns/artifactsmmo-client
Usage
Usage:
<?php declare(strict_types=1); namespace Application; use Eureka\Component\Curl\HttpClient; use Nyholm\Psr7\Factory\Psr17Factory; use Psr\Log\NullLogger; use Velkuns\ArtifactsMMO\Client\Client; use Velkuns\ArtifactsMMO\Client\MyClient; use Velkuns\ArtifactsMMO\Config\ArtifactsMMOConfig; use Velkuns\ArtifactsMMO\Request\RequestBuilder; use Velkuns\ArtifactsMMO\VO\Body\BodyCrafting; use Velkuns\ArtifactsMMO\VO\Body\BodyDestination; require_once(__DIR__ . '/../vendor/autoload.php'); $token = ''; // Your token //~ Config part $config = new ArtifactsMMOConfig('api.artifactsmmo.com', 'https', $token); //~ Client dependencies $httpClient = new HttpClient(userAgent: 'artifactsmmo-client-test/1.0'); $requestFactory = new Psr17Factory(); $uriFactory = new Psr17Factory(); $requestBuilder = new RequestBuilder($requestFactory, $uriFactory, $config); $logger = new NullLogger(); //~ Client $client = new Client($httpClient, $logger, $requestBuilder); //~ Call endpoint and get Value Object with response data $status = $client->getStatus(); // Get status (VO\Status); echo "Server is $status->status\n"; echo "Number of characters online: $status->charactersOnline\n"; //~ Move a character $myClient = new MyClient($httpClient, $logger, $requestBuilder); $myClient->actionMove('character_name', new BodyDestination(1, 1)); //~ Crafting an item $myClient->actionCrafting('character_name', new BodyCrafting('wooden_staff', 1));
Contributing
See the CONTRIBUTING file.
Install / update project
You can install project with the following command:
make install
And update with the following command:
make update
NB: For the components, the composer.lock
file is not committed.
Testing & CI (Continuous Integration)
Tests
You can run tests (with coverage) on your side with following command:
make tests
You can run tests (with coverage) on your side with following command:
make integration
For prettier output (but without coverage), you can use the following command:
make testdox # run tests without coverage reports but with prettified output
Code Style
You also can run code style check with following commands:
make phpcs
You also can run code style fixes with following commands:
make phpcsf
Static Analysis
To perform a static analyze of your code (with phpstan, lvl 9 at default), you can use the following command:
make analyze
Minimal supported version:
make php-min-compatibility
Maximal supported version:
make php-max-compatibility
CI Simulation
And the last "helper" commands, you can run before commit and push, is:
make ci
License
This project is licensed under the MIT License - see the LICENSE
file for details