Help us improve
Share bugs, ideas, or general feedback.
From acc
Generates 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.
npx claudepluginhub dykyi-roman/awesome-claude-code --plugin accHow this skill is triggered — by the user, by Claude, or both
Slash command
/acc:create-template-methodThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Creates Template Method pattern infrastructure for algorithm skeletons with customizable steps.
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.
Covers 26 Gang of Four design patterns with PHP 8.3+ implementations, UML diagrams, and practical use cases.
Applies PHP design patterns—Singleton, Factory, Strategy, Observer, Repository, Decorator, DI—with WooCommerce examples for plugin structure and business logic.
Share bugs, ideas, or general feedback.
Creates Template Method pattern infrastructure for algorithm skeletons with customizable steps.
| Scenario | Example |
|---|---|
| Common algorithm structure | Data import/export with format variations |
| Controlled extension points | Report generation with customizable sections |
| Code reuse across variants | Order processing with type-specific steps |
| Invariant parts protection | Template rendering with hooks |
Path: src/Domain/{BoundedContext}/Template/
Abstract{Name}Template.php — Algorithm skeleton with template methodPath: src/Domain/{BoundedContext}/Template/ or src/Application/{BoundedContext}/
{Variant1}{Name}Template.php — First variant implementation{Variant2}{Name}Template.php — Second variant implementation{Variant3}{Name}Template.php — Third variant implementationPath: src/Domain/{BoundedContext}/ValueObject/
{Name}Result.php — Result value object{Name}Config.php — Configuration value object{Variant}{Name}TemplateTest.php — Individual template testsAbstract{Name}TemplateTest.php — Template skeleton tests| Component | Path |
|---|---|
| Abstract Template | src/Domain/{BoundedContext}/Template/ |
| Concrete Templates (Domain logic) | src/Domain/{BoundedContext}/Template/ |
| Concrete Templates (App logic) | src/Application/{BoundedContext}/ |
| Unit Tests | tests/Unit/Domain/{BoundedContext}/Template/ |
| Component | Pattern | Example |
|---|---|---|
| Abstract | Abstract{Name}Template | AbstractDataImporterTemplate |
| Concrete | {Variant}{Name}Template | CsvDataImporterTemplate |
| Template Method | execute() or process() | execute() |
| Hook Method | before{Step}(), after{Step}() | beforeValidation() |
| Test | {ClassName}Test | CsvDataImporterTemplateTest |
abstract readonly class Abstract{Name}Template
{
public function execute({InputType} $input): {OutputType}
{
$this->validate($input);
$data = $this->extract($input);
$transformed = $this->transform($data);
$result = $this->load($transformed);
$this->afterLoad($result);
return $result;
}
abstract protected function extract({InputType} $input): array;
abstract protected function transform(array $data): array;
protected function validate({InputType} $input): void
{
// Default validation
}
protected function afterLoad({OutputType} $result): void
{
// Hook method - optional override
}
}
final readonly class {Variant}{Name}Template extends Abstract{Name}Template
{
protected function extract({InputType} $input): array
{
// Variant-specific extraction
}
protected function transform(array $data): array
{
// Variant-specific transformation
}
}
// Create templates for different formats
$csvImporter = new CsvDataImporterTemplate();
$jsonImporter = new JsonDataImporterTemplate();
$xmlImporter = new XmlDataImporterTemplate();
// Use same interface
$result = $csvImporter->execute($fileContent);
| Domain | Variants |
|---|---|
| Data Import | CSV, JSON, XML, Excel |
| Report Generation | PDF, Excel, HTML, Email |
| Order Processing | Standard, Express, International |
| Document Rendering | Markdown, LaTeX, HTML |
| Payment Flow | Card, Bank Transfer, Digital Wallet |
| Anti-pattern | Problem | Solution |
|---|---|---|
| Too many abstract methods | Hard to implement | Use hook methods with defaults |
| Public template steps | Breaks encapsulation | Make steps protected/private |
| Mutable state | Side effects | Use readonly classes, pass data |
| Deep inheritance | Complexity | Limit to 2-3 levels max |
| Breaking LSP | Inconsistent behavior | Maintain contract in overrides |
For complete PHP templates and examples, see:
references/templates.md — Abstract Template, Concrete Template, Hook Methods templatesreferences/examples.md — DataImporter, ReportGenerator, OrderProcessor with tests