create-mediator

为 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-mediator":https://skillpi.com/zh/skills/deepskill-05abc6d171ebafd89e9da9316ff90e471d346e6dfb5e12dbd8fb5f0358c932fb。安装前核对上游来源和版本: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-mediator
description: Generates Mediator pattern for PHP 8.4. Creates coordination layer for complex component interactions with event dispatching, request/response handling, and colleague classes. Reduces coupling between interacting objects. Includes unit tests.

Mediator Pattern Generator

Overview

Generates Mediator pattern components for PHP 8.4 to coordinate complex interactions between multiple objects without them referencing each other directly.

When to Use

  • Complex communication between multiple objects
  • Reducing coupling in event-driven systems
  • Coordinating UI components or form elements
  • Command bus / Query bus implementation
  • Chat room / notification hub scenarios
  • Workflow coordination

Generated Components

Component Location Purpose
MediatorInterface src/Application/{Context}/Mediator/ Defines mediation contract
ConcreteMediator src/Application/{Context}/Mediator/ Implements coordination logic
ColleagueInterface src/Application/{Context}/Mediator/Colleague/ Participant contract
AbstractColleague src/Application/{Context}/Mediator/Colleague/ Base with mediator access
ConcreteColleagues src/Application/{Context}/Mediator/Colleague/ Participating components
Tests tests/{Context}/Application/Mediator/ Unit tests

Input Requirements

  1. Name - Mediator name (e.g., "OrderWorkflow", "ChatRoom")
  2. Context - Bounded context (e.g., "Order", "Notification")
  3. Colleagues - List of participating components
  4. Events - Events to coordinate (optional)

Template: Mediator Interface

<?php

declare(strict_types=1);

namespace App\{Context}\Application\Mediator;

use App\{Context}\Application\Mediator\Colleague\ColleagueInterface;

interface {Name}Mediator
{
    public function notify(ColleagueInterface $sender, string $event, mixed $data = null): void;
    public function register(ColleagueInterface $colleague): void;
    public function send(string $request, mixed $data = null): mixed;
}

Template: Colleague Interface

<?php

declare(strict_types=1);

namespace App\{Context}\Application\Mediator\Colleague;

use App\{Context}\Application\Mediator\{Name}Mediator;

interface ColleagueInterface
{
    public function getName(): string;
    public function setMediator({Name}Mediator $mediator): void;
    public function handle(mixed $data): mixed;
}

Template: Abstract Colleague

<?php

declare(strict_types=1);

namespace App\{Context}\Application\Mediator\Colleague;

use App\{Context}\Application\Mediator\{Name}Mediator;

abstract class AbstractColleague implements ColleagueInterface
{
    protected ?{Name}Mediator $mediator = null;

    public function setMediator({Name}Mediator $mediator): void
    {
        $this->mediator = $mediator;
    }

    protected function notify(string $event, mixed $data = null): void
    {
        if ($this->mediator === null) {
            throw new MediatorNotSetException();
        }
        $this->mediator->notify($this, $event, $data);
    }

    protected function send(string $request, mixed $data = null): mixed
    {
        if ($this->mediator === null) {
            throw new MediatorNotSetException();
        }
        return $this->mediator->send($request, $data);
    }
}

File Placement

src/
└── {Context}/
    └── Application/
        └── Mediator/
            ├── {Name}Mediator.php           # Interface
            ├── {Name}MediatorImpl.php       # Implementation
            └── Colleague/
                ├── ColleagueInterface.php   # Base interface
                ├── AbstractColleague.php    # Base class
                └── {Colleague}.php          # Participants

tests/
└── {Context}/
    └── Application/
        └── Mediator/
            └── {Name}MediatorTest.php       # Tests

GRASP Compliance

Principle Implementation
Low Coupling Colleagues don't know each other
Indirection Mediator provides indirection layer
Controller Mediator coordinates use case flow
Pure Fabrication Mediator is artificial coordinating class

References

See references/ for detailed documentation:

  • templates.md - Full Mediator, Colleague, Command Bus, Event Mediator, Chat Room templates
  • examples.md - Real-world examples

当前收录版本

0.0.1

核对来源版本 ↗

质量评测

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

场景价值85/100

亮点

  • 为 PHP 开发者提供中介者模式完整代码生成,显著降低复杂组件间耦合度
  • 覆盖事件分发、请求/响应、同事类协调等核心场景,实用性强
触发精准90/100

亮点

  • 触发描述精准完整,涵盖多种变体和使用边界,用户可清晰识别适用场景
结构规范90/100

亮点

  • 结构清晰,分阶段说明,提供完整模板与文件布局,符合最佳实践
执行可靠85/100

亮点

  • 模板代码规范,包含异常处理与单元测试,执行可靠性高
证据可验 (前四项均值)88/100

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

正文静态检测

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

正文未命中当前规则。

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

权限与使用前检查

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

未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。

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

安全评级与访问范围

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

翻译待完成,请参阅来源文档。

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