laravel:strategy-pattern

📁 jpcaparas/superpowers-laravel 📅 Jan 21, 2026
22
总安装量
12
周安装量
#16914
全站排名
安装命令
npx skills add https://github.com/jpcaparas/superpowers-laravel --skill laravel:strategy-pattern

Agent 安装分布

claude-code 10
gemini-cli 6
antigravity 5
opencode 5
codex 5

Skill 文档

Strategy Pattern

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.