MappedQueueNameResolver::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
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