SimpleQueueVoter::getVote()   A
last analyzed

Complexity

Conditions 2
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.2559

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 9
ccs 3
cts 5
cp 0.6
rs 9.6666
cc 2
eloc 5
nc 3
nop 1
crap 2.2559
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