From superpowers-laravel
Implements Template Method and Strategy patterns in Laravel to stabilize core workflows, enabling extension via new classes instead of editing logic or switches.
npx claudepluginhub jpcaparas/superpowers-laravel --plugin superpowers-laravelThis skill uses the workspace's default tool permissions.
Keep core flows stable; enable extension via small classes.
Implements Strategy pattern in Laravel: shared interface, multiple implementations, factory for runtime selection by key/context, bound via service provider.
Applies PHP design patterns—Singleton, Factory, Strategy, Observer, Repository, Decorator, DI—with WooCommerce examples for plugin structure and business logic.
Generates PHP 8.4 Strategy pattern with interface, concrete strategies, resolver, optional service, and unit tests for interchangeable algorithm families like pricing or sorting.
Share bugs, ideas, or general feedback.
Keep core flows stable; enable extension via small classes.
Use a base class that defines the algorithm skeleton; subclasses override hooks.
abstract class Importer {
final public function handle(string $path): void {
$rows = $this->load($path);
$data = $this->normalize($rows);
$this->validate($data);
$this->save($data);
}
abstract protected function load(string $path): array;
protected function normalize(array $rows): array { return $rows; }
protected function validate(array $data): void {}
abstract protected function save(array $data): void;
}
Define an interface; register implementations; select by key/config.
interface PaymentGateway { public function charge(int $cents, string $currency): string; }
final class StripeGateway implements PaymentGateway { /* ... */ }
final class BraintreeGateway implements PaymentGateway { /* ... */ }
final class PaymentsRegistry {
/** @param array<string,PaymentGateway> $drivers */
public function __construct(private array $drivers) {}
public function for(string $key): PaymentGateway { return $this->drivers[$key]; }
}
Prefer adding a class over editing switch statements. Test implementations in isolation.