Completed
Pull Request — master (#10)
by
unknown
11:04
created

ResolverStrategyService   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 27
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getStrategy() 0 6 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Lamoda\QueueBundle\Service;
5
6
use Lamoda\QueueBundle\Strategy\Delay\DelayStrategyInterface;
7
8
class ResolverStrategyService
9
{
10
    public const DEFAULT_STRATEGY = 'default_delay_strategy';
11
12
    /**
13
     * @var array
14
     */
15
    protected $handlers;
16
17
    /**
18
     * @var array
19
     */
20
    protected $queuesConfiguration;
21
22 1
    public function __construct(iterable $handlers, array $queuesConfiguration = [])
23
    {
24 1
        $this->handlers            = iterator_to_array($handlers);
25 1
        $this->queuesConfiguration = $queuesConfiguration;
26 1
    }
27
28 1
    public function getStrategy(string $queueName): DelayStrategyInterface
29
    {
30 1
        $strategyKey = $this->queuesConfiguration[$queueName] ?? self::DEFAULT_STRATEGY;
31
32 1
        return $this->handlers[$strategyKey];
33
    }
34
}
35