From acc
Generates Bridge pattern for PHP 8.4 projects, creating abstraction, refined abstraction, implementor interface, concrete implementors, and unit tests in Domain/Infrastructure structure. For decoupling with multiple variation dimensions or runtime switching.
How this skill is triggered — by the user, by Claude, or both
Slash command
/acc:create-bridgeThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Creates Bridge pattern infrastructure for separating abstraction from implementation.
Creates Bridge pattern infrastructure for separating abstraction from implementation.
| Scenario | Example |
|---|---|
| Multiple dimensions of variation | Notification types × channels |
| Avoid class explosion | Shape × rendering method |
| Runtime implementation switching | Database drivers |
| Platform independence | UI × OS |
Path: src/Domain/{BoundedContext}/
{Name}ImplementorInterface.php — Low-level operationsPath: src/Domain/{BoundedContext}/
Abstract{Name}.php — High-level interfacePath: src/Domain/{BoundedContext}/
{Type}{Name}.php — Specialized abstractionsPath: src/Infrastructure/{BoundedContext}/
{Platform}{Name}Implementor.php — Platform implementations{ClassName}Test.php — Bridge behavior verification| Component | Path |
|---|---|
| Abstraction | src/Domain/{BoundedContext}/ |
| RefinedAbstraction | src/Domain/{BoundedContext}/ |
| Implementor Interface | src/Domain/{BoundedContext}/ |
| ConcreteImplementor | src/Infrastructure/{BoundedContext}/ |
| Unit Tests | tests/Unit/ |
| Component | Pattern | Example |
|---|---|---|
| Abstraction | Abstract{Name} | AbstractNotification |
| RefinedAbstraction | {Type}{Name} | UrgentNotification |
| Implementor Interface | {Name}ImplementorInterface | NotificationImplementorInterface |
| ConcreteImplementor | {Platform}{Name}Implementor | EmailNotificationImplementor |
abstract readonly class Abstract{Name}
{
public function __construct(
protected {Name}ImplementorInterface $implementor
) {}
abstract public function {operation}({params}): {returnType};
}
final readonly class {Type}{Name} extends Abstract{Name}
{
public function {operation}({params}): {returnType}
{
{preprocessing}
return $this->implementor->{implementorMethod}({params});
}
}
$email = new EmailNotificationImplementor();
$urgent = new UrgentNotification($email);
$urgent->send($message);
// Switch implementation
$sms = new SmsNotificationImplementor();
$urgent = new UrgentNotification($sms);
$urgent->send($message);
| Bridge | Purpose |
|---|---|
| NotificationBridge | Type × Channel (Email/SMS/Push) |
| ReportBridge | Format × Generator (PDF/Excel/CSV) |
| DatabaseBridge | Query × Driver (MySQL/PostgreSQL) |
| PaymentBridge | Gateway × Provider (Stripe/PayPal) |
| Anti-pattern | Problem | Solution |
|---|---|---|
| Missing Abstraction | Direct implementor use | Use abstraction layer |
| Tight Coupling | Abstraction knows concrete implementor | Depend on interface |
| Single Implementation | No variation | Use simple inheritance |
| Leaky Abstraction | Exposes implementor details | Hide implementation |
For complete PHP templates and examples, see:
references/templates.md — Abstraction, refined abstraction, implementor templatesreferences/examples.md — Notification, report bridges with unit testsnpx claudepluginhub dykyi-roman/awesome-claude-code --plugin accGenerates Template Method pattern for PHP 8.4: abstract algorithm skeleton with customizable steps, concrete implementations, hooks, optional value objects, and unit tests. For reusable algorithms with variants like data processing.
Decouple an abstraction from its implementation so both can vary independently, avoiding exponential class hierarchies that result from combining them through inheritance. Best for structural design patterns in OOP.
Implements the Bridge pattern to separate abstraction from implementation, enabling independent variation along two dimensions (e.g., shape+renderer, notification+channel).