Laravel strategy pattern
Skill ComeOnOliver/skillshub/skills/noartem/skills/laravel-strategy-pattern
🧠The right skill, one API call. AI agent skills registry with token-efficient skill resolution. 5,000+ skills from 500+ top repos.
npx -y skills add ComeOnOliver/skillshub --skill laravel-strategy-patternAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
SKILL.md
0.5 KB, as published. Nobody here has run it
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.