laravel:strategy-pattern

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

jpcaparas/superpowers-laravel92 installsMITSynced Aug 26

Works with

Claude CodeCursorCodex CLIGitHub CopilotGemini CLI
---
name: laravel:strategy-pattern
description: Use the Strategy pattern to select behavior at runtime; bind multiple implementations to a shared interface
license: MIT
---

# 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.

More Backend Frameworks skills

← All Backend Frameworks skills

Check your AI visibility

One URL in, a 0–100 score and the exact fixes out.

RUN THE CHECK

Browse all the tools

15 tools across six categories
13 of them never send your data anywhere

Free · No signup · No trial clock

SEE THE DIRECTORY