laravel-strategy-pattern
10
总安装量
4
周安装量
#31109
全站排名
安装命令
npx skills add https://github.com/noartem/laravel-vue-skills --skill laravel-strategy-pattern
Agent 安装分布
codex
4
opencode
3
gemini-cli
3
antigravity
2
amp
2
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.