skills/noartem/skills/laravel-strategy-pattern

laravel-strategy-pattern

SKILL.md

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.

Weekly Installs
11
Repository
noartem/skills
GitHub Stars
5
First Seen
Jan 30, 2026
Installed on
opencode10
cursor9
gemini-cli8
github-copilot8
codex8
kimi-cli8