| Total Complexity | 7 |
| Total Lines | 57 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | trait DelayStrategyResolverTrait |
||
| 13 | { |
||
| 14 | private function createDelayStrategyResolver(array $strategiesByQueues): DelayStrategyResolver |
||
| 15 | { |
||
| 16 | $arithmeticStrategy = new ArithmeticProgressionStrategy(100, 4); |
||
| 17 | $geometricStrategy = new GeometricProgressionStrategy(30, 2); |
||
| 18 | $defaultStrategy = new GeometricProgressionStrategy(60, 3); |
||
| 19 | |||
| 20 | $strategies = [ |
||
| 21 | 'arithmetic_strategy_key' => $arithmeticStrategy, |
||
| 22 | 'geometric_strategy_key' => $geometricStrategy, |
||
| 23 | 'default_delay_strategy' => $defaultStrategy, |
||
| 24 | ]; |
||
| 25 | |||
| 26 | return new DelayStrategyResolver($this->createStrategiesList($strategies), $strategiesByQueues); |
||
| 27 | } |
||
| 28 | |||
| 29 | private function createStrategiesList(array $strategies) |
||
| 30 | { |
||
| 31 | return new class($strategies) implements \Iterator { |
||
| 32 | /** |
||
| 33 | * @var array |
||
| 34 | */ |
||
| 35 | protected $strategies; |
||
| 36 | |||
| 37 | public function __construct(array $strategies) |
||
| 41 | |||
| 42 | public function current() |
||
| 46 | |||
| 47 | public function next() |
||
| 51 | |||
| 52 | public function key() |
||
| 56 | |||
| 57 | public function valid() |
||
| 61 | |||
| 62 | public function rewind() |
||
| 66 | }; |
||
| 67 | } |
||
| 68 | } |
||
| 69 |