ConsumeEvent::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
crap 1
1
<?php
2
3
namespace TreeHouse\Queue\Event;
4
5
use Symfony\Contracts\EventDispatcher\Event;
6
use TreeHouse\Queue\Amqp\EnvelopeInterface;
7
8
class ConsumeEvent extends Event
9
{
10
    /**
11
     * @var EnvelopeInterface
12
     */
13
    private $envelope;
14
15
    /**
16
     * @var mixed
17
     */
18
    private $result;
19
20
    /**
21
     * @var bool
22
     */
23
    private $continueConsuming;
24
25
    /**
26
     * @param EnvelopeInterface $envelope The envelope that was consumed
27
     * @param mixed             $result   The result of the consumed message
28
     * @param bool              $continue  Whether to continue consuming or stop the thread blocking
29
     */
30 3
    public function __construct(EnvelopeInterface $envelope, $result = null, $continue = true)
31
    {
32 3
        $this->envelope = $envelope;
33 3
        $this->result = $result;
34 3
        $this->continueConsuming = $continue;
35 3
    }
36
37
    /**
38
     * @return EnvelopeInterface
39
     */
40 1
    public function getEnvelope()
41
    {
42 1
        return $this->envelope;
43
    }
44
45
    /**
46
     * @param mixed $result
47
     */
48 1
    public function setResult($result)
49
    {
50 1
        $this->result = $result;
51 1
    }
52
53
    /**
54
     * @return mixed
55
     */
56 1
    public function getResult()
57
    {
58 1
        return $this->result;
59
    }
60
61
    /**
62
     * @return bool
63
     */
64 1
    public function shouldContinueConsuming()
65
    {
66 1
        return $this->continueConsuming;
67
    }
68
69
    /**
70
     * Marks the event as to not continue consuming after this.
71
     */
72
    public function stopConsuming()
73
    {
74
        $this->continueConsuming = false;
75
    }
76
}
77