From superpowers-laravel
Implements Strategy pattern in Laravel: shared interface, multiple implementations, factory for runtime selection by key/context, bound via service provider.
npx claudepluginhub jpcaparas/superpowers-laravel --plugin superpowers-laravelThis skill uses the workspace's default tool permissions.
Create a common interface and multiple implementations. Choose a strategy by key or context.
Generates PHP 8.4 Strategy pattern with interface, concrete strategies, resolver, optional service, and unit tests for interchangeable algorithm families like pricing or sorting.
Implements Template Method and Strategy patterns in Laravel to stabilize core workflows, enabling extension via new classes instead of editing logic or switches.
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.
Create a common interface and multiple implementations. Choose a strategy by key or context.
interface TaxCalculator { public function for(int $cents): int; }
final class NzTax implements TaxCalculator { /* ... */ }
final class AuTax implements TaxCalculator { /* ... */ }
final class TaxFactory {
public function __construct(private array $drivers) {}
public function forCountry(string $code): TaxCalculator { return $this->drivers[$code]; }
}
Register in a service provider and inject the factory where needed.