承接 rustem-kaimolla/kz-currency-rates 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

rustem-kaimolla/kz-currency-rates

最新稳定版本:v1.0.0

Composer 安装命令:

composer require rustem-kaimolla/kz-currency-rates

包简介

PHP-библиотека для получения курсов валют с НБ РК

README 文档

README

PHP License Packagist Downloads

Lightweight PHP library for getting exchange rates from the official API of the National Bank of Kazakhstan.

📡 Source: https://nationalbank.kz/rss/get_rates.cfm?fdate=dd.mm.YYYY

🚀 Installation

composer require rusdev/kz-currency-rates

🧱 Stack

  • PHP 8.1+
  • Guzzle HTTP client
  • PSR-4 autoload

📦 Quick start

use Currency\Requests\RateRequestBuilder;
use Currency\Parsers\XmlRateParser;
use Currency\Services\RateFetcher;
use GuzzleHttp\Client;

$builder = (new RateRequestBuilder())->forDate('12.05.2025');
$parser = new XmlRateParser();

$fetcher = new RateFetcher(
    $builder->build(),
    $parser
);

$rates = $fetcher->getAllRates();

foreach ($rates as $rate) {
    echo $rate->code . ': ' . $rate->rate . PHP_EOL;
}

📌 Receiving a specific currency

$usd = $fetcher->getRate('USD');

echo "USD/KZT: {$usd->rate}";

🧠 Filtering major currencies (Specification)

use Currency\Filters\MajorCurrencySpecification;

$spec = new MajorCurrencySpecification();

$majorRates = array_filter($rates, fn($rate) => $spec->isSatisfiedBy($rate));

foreach ($majorRates as $rate) {
    echo $rate->currency() . ': ' . $rate->value() . PHP_EOL;
}

🧪 Tests

composer test

Test Coverage:

  • XmlRateParser
  • RateRequestBuilder
  • CurrencyRateDTO
  • MajorCurrencySpecification
  • RateFetcher (с Guzzle mock)

📄 License

MIT.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-05-12