承接 slawe/climbing-grade-conversions 相关项目开发

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

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

slawe/climbing-grade-conversions

Composer 安装命令:

composer require slawe/climbing-grade-conversions

包简介

Small PHP library for converting rock climbing grades between multiple grading systems.

README 文档

README

Small PHP library for converting rock climbing grades between multiple grading systems. It started as a DDD / clean-architecture learning playground and evolved into a reusable package.

Supported Grading Systems

Currently supported (out of the box):

  • French Sport Scale (FR) - "6a", "7c+", etc.
  • UIAA Scale (UIAA) - "VI+", "IX-", etc.
  • Yosemite Decimal System (YDS) - "5.10a", "5.12d", etc.
  • British Technical (UK-tech) - "4a", "6c", etc.
  • British Adjectival (UK-adj) - "VS", "E3", etc.
  • Saxon Scale (SAXON) - "VIIa", "IXc", etc.
  • Australian Ewbank (AU) - "18", "24", etc.
  • South African Ewbank (SA) - "19", "25", etc.
  • Finnish Scale (FIN) - "6-", "7+", etc.
  • Norwegian Scale (NO) - "6", "7+", etc.
  • Brazilian Technical (BR) - "VIsup", "8b", etc.
  • Polish Kurtyka's Scale (PO) - "VI.1+", "VI.4", etc.
  • American Hueco/V-Scale (V) - "V3", "V7", etc.
  • French Fontainebleau (FONT) - "7A+", "6C", etc.
  • ...(You can add more by implementing a scale class and registering it.)

Installation

composer require slawe/climbing-grade-conversions

or

git clone git@github.com:slawe/climbing-grade-conversions.git
cd climbing-grade-conversions
composer install

The package ships with a CSV-backed repository by default. Configure the CSV path via Climb\Grades\Infrastructure\Config\GradeConfig::csvPath().

Basic Usage

Convert between any supported grading systems with a simple and fluent API:

use Climb\Grades\Infrastructure\Bootstrap\GradeConversion;
use Climb\Grades\Domain\Value\GradeSystem;

// Convert a French 6c+ to YDS
$ydsGrades = GradeConversion::from('6c+', 'fr')->to(GradeSystem::YDS);
echo $ydsGrades[0]->value(); // "5.11b"

// Convert a French 7a to all other systems
$allGrades = GradeConversion::from('7a', 'fr')->toAll();

// Include the source system in the result
$allWithSource = GradeConversion::from('7a', 'fr')->toAll(includeSource: true);

// Get a single result with explicit policies (useful when multiple grade mappings exist)
use Climb\Grades\Domain\Service\PrimaryIndexPolicy;
use Climb\Grades\Domain\Service\TargetVariantPolicy;

$singleGrade = GradeConversion::from('7a', 'fr')
    ->towards(GradeSystem::BR)
    ->single(
        PrimaryIndexPolicy::LOWEST,
        TargetVariantPolicy::LAST
    );

Advanced Usage

Using a Different CSV Data Source

You can use a different CSV data source by providing your own path:

use Climb\Grades\Infrastructure\Config\GradeServices;

// Global configuration (applies to all future conversions)
GradeServices::useCsv('/path/to/your/custom-grades.csv');

// Then use the normal API
$grades = GradeConversion::from('6c+', 'fr')->to(GradeSystem::YDS);

Using a Custom Data Repository

For advanced use cases, you can implement your own GradeScaleDataRepository (e.g., database-backed):

use Climb\Grades\Infrastructure\Config\GradeServices;

// Create your custom repository implementing GradeScaleDataRepository
$myRepo = new MyDatabaseRepository($dbConnection);

// Use it globally
GradeServices::useRepository($myRepo);

// Or just for one specific conversion service
$service = GradeServices::conversion($myRepo);

CLI usage

A small helper lives at bin/grades.

Positional:

  • <gradeValue> - e.g. 6c+, 7a
  • <gradeSystem> - e.g. FR, UIAA, YDS
  • [targetSystem] - if omitted, converts to all other systems (range)

Options:

  • --single (or -1) - return one result (instead of a list)
  • --source-policy=lowest|middle|highest - how to pick the source index if the grade spans multiple (default: lowest)
  • --target-policy=first|middle|last - which target variant to pick if the cell has multiple values (default: first)
  • --include-source - when converting to all systems, include the source too
  • --help - show help

Examples:

php bin/grades 6c+ fr
php bin/grades 6c+ fr yds
php bin/grades 7a fr br --single --target-policy=last
php bin/grades 6c+ fr --include-source

When installed via Composer in another project, the command is also available as:

vendor/bin/grades 6c+ fr

Architecture

This library follows DDD and clean architecture principles:

  • Domain layer: Contains core business logic (grade systems, conversion algorithms)
  • Infrastructure layer: Provides data access and bootstrap utilities
  • Bootstrap facade: Offers a convenient entry point for typical usage scenarios

Core components:

Extending with a new grading system

  1. Add a case to GradeSystem enum.
  2. Create a scale class extending AbstractGradeScale and implement system(): GradeSystem; its data will come from the repository’s column for that system.
  3. Register the scale in your composition root (GradeServices or your own factory).

No other changes are needed: GradeConversionService will pick it up automatically.

Development

Run the test suite:

composer test

Run CLI locally:

php bin/grades 6c+ FR
php bin/grades 6c+ FR YDS

Changelog

See CHANGELOG.md for release notes.

Latest: v0.3.1 — Release: Architecture refactoring and performance improvements.

License

Released under the MIT License.

Copyright © 2025 slawe

slawe/climbing-grade-conversions 适用场景与选型建议

slawe/climbing-grade-conversions 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 11 月 12 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「library」 「climbing」 「conversion」 「converter」 「french」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 slawe/climbing-grade-conversions 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 slawe/climbing-grade-conversions 我们能提供哪些服务?
定制开发 / 二次开发

基于 slawe/climbing-grade-conversions 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

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