mcpField
L
laravel-strategy-pattern

laravel-strategy-pattern

github.com/noartemDevelopment1371 installsUpdated 3w ago
Repository

About laravel-strategy-pattern

A Laravel skill for structuring interchangeable strategies behind a shared interface. It shows how to select implementations by key or context and register a factory through a service provider.

Key features

  1. 01Shared strategy interface
  2. 02Multiple interchangeable implementations
  3. 03Factory selection by country code
  4. 04Service provider registration

Use cases

  1. 01Choosing tax calculation rules by country
  2. 02Injecting a strategy factory into application services

Install

Copy the command and run it in a terminal.

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

After installing, type/laravel-strategy-patternin Claude Code to confirm it loaded.

Details

From the project README

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.

Comments

Markdown supported