Idle::isExecutionInterrupted()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BinaryCube\CarrotMQ\Event\Consumer;
6
7
use Interop\Queue\Context;
8
use BinaryCube\CarrotMQ\Event\Event;
9
use BinaryCube\CarrotMQ\Entity\Queue;
10
11
/**
12
 * Class Idle
13
 */
14
class Idle extends Event
15
{
16
17
    /**
18
     * @var Queue
19
     */
20
    private $queue;
21
22
    /**
23
     * @var Context
24
     */
25
    private $context;
26
27
    /**
28
     * @var boolean
29
     */
30
    private $executionInterrupted;
31
32
    /**
33
     * @var integer
34
     */
35
    private $exitStatus;
36
37
    /**
38
     * @return string
39
     */
40
    public static function name(): string
41
    {
42
        return 'consumer.event.idle';
43
    }
44
45
    /**
46
     * Constructor.
47
     *
48
     * @param Queue   $queue
49
     * @param Context $context
50
     */
51
    public function __construct(Queue $queue, Context $context)
52
    {
53
        $this->queue                = $queue;
54
        $this->context              = $context;
55
        $this->executionInterrupted = false;
56
    }
57
58
    /**
59
     * @return Queue
60
     */
61
    public function queue(): Queue
62
    {
63
        return $this->queue;
64
    }
65
66
    /**
67
     * @return Context
68
     */
69
    public function context(): Context
70
    {
71
        return $this->context;
72
    }
73
74
    /**
75
     * @return int|null
76
     */
77
    public function exitStatus(): ?int
78
    {
79
        return $this->exitStatus;
80
    }
81
82
    /**
83
     * @return bool
84
     */
85
    public function isExecutionInterrupted(): bool
86
    {
87
        return $this->executionInterrupted;
88
    }
89
90
    /**
91
     * @param int|null $exitStatus
92
     *
93
     * @return void;
94
     */
95
    public function interruptExecution(?int $exitStatus = null): void
96
    {
97
        $this->exitStatus           = $exitStatus;
98
        $this->executionInterrupted = true;
99
    }
100
101
}
102