SimpleQueueVoter::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

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