SimpleQueueVoter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 77.78%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 3
c 2
b 0
f 1
lcom 1
cbo 2
dl 0
loc 22
ccs 7
cts 9
cp 0.7778
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getVote() 0 9 2
1
<?php
2
3
namespace MGDigital\BusQue\QueueResolver;
4
5
use MGDigital\BusQue\Exception\QueueResolverException;
6
use MGDigital\BusQue\QueueResolverInterface;
7
8
class SimpleQueueVoter implements QueueVoterInterface
9
{
10
11
    private $resolver;
12
    private $confidence;
13
14 4
    public function __construct(QueueResolverInterface $resolver, int $confidence = QueueVote::CONFIDENCE_NEUTRAL)
15
    {
16 4
        $this->resolver = $resolver;
17 4
        $this->confidence = $confidence;
18 4
    }
19
20 2
    public function getVote($command)
21
    {
22
        try {
23 2
            $queueName = $this->resolver->resolveQueueName($command);
24 2
            return new QueueVote($queueName, $this->confidence);
25
        } catch (QueueResolverException $e) {
26
            // Don't vote if the resolver cannot name a queue.
27
        }
28
    }
29
}
30