Agent skill

laravel-strategy-pattern

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

Stars 6
Forks 0

Install this agent skill to your Project

npx add-skill https://github.com/noartem/skills/tree/main/skills/laravel-strategy-pattern

SKILL.md

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.

Expand your agent's capabilities with these related and highly-rated skills.

Didn't find tool you were looking for?

Be as detailed as possible for better results