MappedQueueNameResolver   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 6
dl 0
loc 14
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A resolveRoutingKeyFor() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Enqueue\SimpleBus\Routing;
6
7
use SimpleBus\Asynchronous\Routing\RoutingKeyResolver;
8
9
final class MappedQueueNameResolver implements RoutingKeyResolver
10
{
11
    private $map;
12
    private $default;
13
14
    public function __construct(array $map, string $default)
15
    {
16
        $this->map = $map;
17
        $this->default = $default;
18
    }
19
20
    public function resolveRoutingKeyFor($message): string
21
    {
22
        return $this->map[get_class($message)] ?? $this->default;
23
    }
24
}
25