velkuns/artifactsmmo-client 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

velkuns/artifactsmmo-client

最新稳定版本:3.3.0

Composer 安装命令:

composer require velkuns/artifactsmmo-client

包简介

PHP Client for Artifacts MMO Game Code

README 文档

README

Current version Supported PHP version CI Quality Gate Status Coverage

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

统计信息

  • 总下载量: 29
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-08-11