# Laravel Strategy Pattern

> Use the Strategy pattern to select behavior at runtime; bind multiple implementations to a shared interface

- Skill: `noartem/laravel-strategy-pattern` (Agent Skill)
- Install (CLI): `npx skillmds@latest add noartem/laravel-strategy-pattern`
- Raw SKILL.md: https://api.skillmd.com/api/skills/noartem/laravel-strategy-pattern/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: noartem (https://skillmd.com/u/noartem)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/noartem/laravel-strategy-pattern

---


# Strategy Pattern

Create a common interface and multiple implementations. Choose a strategy by key or context.

```php
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.

