Completed
Push — master ( 82e59a...afe19b )
by Mike
03:27
created

SimpleQueueVoter::getVote()   A

Complexity

Conditions 2
Paths 3

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.2559

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 8
ccs 3
cts 5
cp 0.6
rs 9.4285
c 1
b 0
f 0
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) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
26
        }
27
    }
28
}
29