Start   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 103
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
eloc 18
c 1
b 0
f 0
dl 0
loc 103
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A interruptExecution() 0 4 1
A startTime() 0 3 1
A __construct() 0 9 1
A context() 0 3 1
A name() 0 3 1
A isExecutionInterrupted() 0 3 1
A exitStatus() 0 3 1
A queue() 0 3 1
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 Start
13
 */
14
class Start 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 float
29
     */
30
    private $startTime;
31
32
    /**
33
     * @var boolean
34
     */
35
    private $executionInterrupted;
36
37
    /**
38
     * @var integer
39
     */
40
    private $exitStatus;
41
42
    /**
43
     * @return string
44
     */
45
    public static function name(): string
46
    {
47
        return 'consumer.event.start';
48
    }
49
50
    /**
51
     * Constructor.
52
     *
53
     * @param Queue   $queue
54
     * @param Context $context
55
     * @param float   $startTime
56
     */
57
    public function __construct(
58
        Queue $queue,
59
        Context $context,
60
        float $startTime
61
    ) {
62
        $this->queue                = $queue;
63
        $this->context              = $context;
64
        $this->startTime            = $startTime;
65
        $this->executionInterrupted = false;
66
    }
67
68
    /**
69
     * @return Queue
70
     */
71
    public function queue(): Queue
72
    {
73
        return $this->queue;
74
    }
75
76
    /**
77
     * @return Context
78
     */
79
    public function context(): Context
80
    {
81
        return $this->context;
82
    }
83
84
    /**
85
     * @return float
86
     */
87
    public function startTime(): float
88
    {
89
        return $this->startTime;
90
    }
91
92
    /**
93
     * @return int|null
94
     */
95
    public function exitStatus(): ?int
96
    {
97
        return $this->exitStatus;
98
    }
99
100
    /**
101
     * @return bool
102
     */
103
    public function isExecutionInterrupted(): bool
104
    {
105
        return $this->executionInterrupted;
106
    }
107
108
    /**
109
     * @param int|null $exitStatus
110
     *
111
     * @return void
112
     */
113
    public function interruptExecution(?int $exitStatus = null): void
114
    {
115
        $this->exitStatus           = $exitStatus;
116
        $this->executionInterrupted = true;
117
    }
118
119
}
120