laravel-strategy-pattern

v2026.09.24

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

GitHub
Install command
npx skhub add noartem/laravel-strategy-pattern
Markdown
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.

Discovery
Tags

No tags published for this skill.

Version
Latest version metadata

Version

v2026.09.24

Published

Sep 24, 2026

Category

Uncategorized

License

Not specified

Source path

skills/laravel-strategy-pattern

Default branch

main

Latest commit

0002f35

Tree SHA

3db1f86