for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Lamoda\QueueBundle\Service;
use Lamoda\QueueBundle\Strategy\Delay\DelayStrategyInterface;
class ResolverStrategyService
{
public const DEFAULT_STRATEGY = 'default_delay_strategy';
/**
* @var array
*/
protected $handlers;
protected $queuesConfiguration;
public function __construct(iterable $handlers, array $queuesConfiguration = [])
$this->handlers = iterator_to_array($handlers);
$this->queuesConfiguration = $queuesConfiguration;
}
public function getStrategy(string $queueName): DelayStrategyInterface
$strategyKey = $this->queuesConfiguration[$queueName] ?? self::DEFAULT_STRATEGY;
return $this->handlers[$strategyKey];