From acc
Generates Adapter pattern for PHP 8.4 to convert incompatible interfaces, wrap legacy code or external libraries like Stripe/AWS SDKs. Includes target interfaces, adapters, and unit tests.
How this skill is triggered — by the user, by Claude, or both
Slash command
/acc:create-adapterThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Creates Adapter pattern infrastructure for converting incompatible interfaces into expected ones.
Creates Adapter pattern infrastructure for converting incompatible interfaces into expected ones.
| 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 |
Path: src/Domain/{BoundedContext}/
{Name}Interface.php — Expected interface contractPath: src/Infrastructure/{BoundedContext}/Adapter/
{Provider}{Name}Adapter.php — Converts adaptee to target interface{Legacy}{Name}Adapter.php — Wraps legacy code{External}{Name}Adapter.php — Wraps third-party library{AdapterName}Test.php — Adapter behavior verification| 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/ |
| Component | Pattern | Example |
|---|---|---|
| Target Interface | {Name}Interface | PaymentGatewayInterface |
| Adapter | {Provider}{Name}Adapter | StripePaymentGatewayAdapter |
| Test | {ClassName}Test | StripePaymentGatewayAdapterTest |
interface {Name}Interface
{
public function {operation}({params}): {returnType};
}
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};
}
}
// 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);
| 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-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 |
For complete PHP templates and examples, see:
references/templates.md — Target Interface, Adapter templates for payment, storage, messagingreferences/examples.md — Stripe, PayPal, AWS S3, legacy user adapters with unit testsnpx claudepluginhub dykyi-roman/awesome-claude-code --plugin accConverts incompatible class interfaces so they work together, wrapping legacy or third-party code without modifying it. Useful when integrating code with mismatched APIs.
Generates Decorator pattern for PHP 8.4: interface, abstract decorator, concrete decorators (logging, caching, metrics, transactional), optional factory, and unit tests. For dynamic behavior without inheritance.
Wraps incompatible interfaces (Object Adapter via composition, async/promise adaptation, two-way adaptation) to make them work together without modifying source code. Useful when integrating third-party libraries or legacy components.