mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-18 16:01:42 +00:00
- Create an Ioc container and set factories and services - Adjust degrading Strategies - Clean up and do global chores here and there and avoid Dry code - Write unit and integration tests and ensure correct business logic
25 lines
549 B
PHP
25 lines
549 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use GildedRose\Services\AbstractDegradingStrategyFactory;
|
|
use GildedRose\Services\DegradingStrategyFactory;
|
|
|
|
/**
|
|
* Here We set Bindings between Interfaces and abstraction to implementation
|
|
*/
|
|
const BINDINGS =
|
|
[
|
|
AbstractDegradingStrategyFactory::class => DegradingStrategyFactory::class
|
|
];
|
|
|
|
// Helper Method to get implementation
|
|
function resolve(string $interface)
|
|
{
|
|
try {
|
|
return BINDINGS[$interface];
|
|
} catch (Throwable $e) {
|
|
throw new Exception('Cannot Find Implementation');
|
|
}
|
|
}
|