create-adapter

为 PHP 8.4 生成适配器模式的代码。用于将不兼容接口相互转换,以封装遗留代码或外部库的接口适配,包含相应的单元测试。

仓库最近推送
GitHub Stars
109
Forks
26
Issues / PRs
1

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "create-adapter":https://skillpi.com/zh/skills/deepskill-407cc79508495fdfdd1d6cdd96bed420c89044a712ec208dabdc26d1810cd7af。安装前核对上游来源和版本:https://github.com/dykyi-roman/awesome-claude-code。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

github.com

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

为 PHP 8.4 生成适配器模式的代码。用于将不兼容接口相互转换,以封装遗留代码或外部库的接口适配,包含相应的单元测试。

0 下载

介绍来源: third_party · dykyi-roman · 0.0.1 参考来源

SkillPi 解读

能完成的任务
翻译待完成,请参阅来源文档。
适合谁
翻译待完成,请参阅来源文档。
实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: create-adapter
description: Generates Adapter pattern for PHP 8.4. Converts incompatible interfaces, wraps legacy code and external libraries. Includes unit tests.

Adapter Pattern Generator

Creates Adapter pattern infrastructure for converting incompatible interfaces into expected ones.

When to Use

Scenario Example
Legacy code integration Wrap old API with new interface
Third-party library wrapping Stripe SDK, AWS SDK adapters
Interface standardization Multiple payment gateways with unified interface
Backward compatibility Support old and new interfaces

Component Characteristics

Target Interface

  • Defines expected operations
  • Client code depends on this
  • Domain layer contract

Adapter

  • Implements target interface
  • Wraps adaptee (existing class)
  • Translates calls between interfaces

Adaptee

  • Existing incompatible class
  • Legacy code or external library
  • Not modified by adapter

Generation Process

Step 1: Generate Target Interface

Path: src/Domain/{BoundedContext}/

  1. {Name}Interface.php — Expected interface contract

Step 2: Generate Adapter

Path: src/Infrastructure/{BoundedContext}/Adapter/

  1. {Provider}{Name}Adapter.php — Converts adaptee to target interface
  2. {Legacy}{Name}Adapter.php — Wraps legacy code
  3. {External}{Name}Adapter.php — Wraps third-party library

Step 3: Generate Tests

  1. {AdapterName}Test.php — Adapter behavior verification

File Placement

Component Path
Target Interface src/Domain/{BoundedContext}/
Adapter src/Infrastructure/{BoundedContext}/Adapter/
Adaptee (existing) External library or legacy code
Unit Tests tests/Unit/Infrastructure/{BoundedContext}/Adapter/

Naming Conventions

Component Pattern Example
Target Interface {Name}Interface PaymentGatewayInterface
Adapter {Provider}{Name}Adapter StripePaymentGatewayAdapter
Test {ClassName}Test StripePaymentGatewayAdapterTest

Quick Template Reference

Target Interface

interface {Name}Interface
{
    public function {operation}({params}): {returnType};
}

Adapter

final readonly class {Provider}{Name}Adapter implements {Name}Interface
{
    public function __construct(
        private {Adaptee} $adaptee
    ) {}

    public function {operation}({params}): {returnType}
    {
        // Translate params to adaptee format
        $adapteeResult = $this->adaptee->{adapteeMethod}({adapteeParams});

        // Convert result to target format
        return {convertedResult};
    }
}

Usage Example

// Stripe SDK is the adaptee
$stripeClient = new \Stripe\StripeClient($apiKey);

// Adapter makes it compatible with our interface
$paymentGateway = new StripePaymentGatewayAdapter($stripeClient);

// Use through our domain interface
$result = $paymentGateway->charge($amount, $token);

Common Adapters

Adapter Purpose
PaymentGatewayAdapter Wrap Stripe, PayPal, Square APIs
StorageAdapter Wrap AWS S3, Google Cloud Storage
MessengerAdapter Wrap Slack, Discord, Telegram APIs
EmailAdapter Wrap SendGrid, Mailgun, AWS SES
CacheAdapter Wrap Redis, Memcached, APCu
LoggerAdapter Wrap Monolog, Syslog, custom loggers

Anti-patterns to Avoid

Anti-pattern Problem Solution
Leaky Adapter Exposing adaptee details Return only target interface types
Multiple Responsibilities Adapter doing business logic Keep adapters focused on translation
Tight Coupling Adapter depends on concrete adaptee Accept interface when possible
Heavy Translation Complex conversions in adapter Extract translator services
Missing Error Handling Adaptee exceptions leak Catch and convert to domain exceptions

References

For complete PHP templates and examples, see:

  • references/templates.md — Target Interface, Adapter templates for payment, storage, messaging
  • references/examples.md — Stripe, PayPal, AWS S3, legacy user adapters with unit tests

当前收录版本

0.0.1

核对来源版本 ↗

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值85/100

亮点

  • 提供 PHP 8.4 适配器模式生成能力,适用于接口转换、遗留代码封装和第三方库集成
  • 覆盖支付、存储、消息、邮件、缓存、日志等常见适配器场景,实用性强
触发精准95/100

亮点

  • description 明确描述核心功能与用途,触发词精准完整,边界清晰
结构规范95/100

亮点

  • 文档结构完整,包含使用场景、组件说明、生成步骤、文件路径、命名规范、模板、示例和反模式
  • 分步骤清晰,有端到端示例和代码模板,frontmatter 完整
执行可靠65/100

待提升项

  • 引用文件缺失 原报告严重程度:重大

    SKILL.md 中引用了 references/templates.md 和 references/examples.md,但实际未传入这些文件

    改进建议:请补充 references 目录下的 templates.md 和 examples.md 文件,或移除相关引用

亮点

  • 代码生成逻辑清晰,模板规范,具备良好的可执行性基础
证据可验 (前四项均值)85/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

  • 账号、密钥或授权

    使用专用、最小权限账号,不把密钥粘贴到公开内容或命令日志;核对接收数据的服务与租户。

    主文档提及 · 第 118 行

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。