Completed
Push — master ( ca959b...d3c999 )
by Tomasz
06:06
created

QueueWorkerRunEvent::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 2
crap 2
1
<?php
2
3
namespace Gendoria\CommandQueueBundle\Event;
4
5
use Gendoria\CommandQueue\Worker\WorkerInterface;
6
use Symfony\Component\EventDispatcher\Event;
7
8
/**
9
 * Event raised, when queue worker is run.
10
 *
11
 * @author Tomasz Struczyński <[email protected]>
12
 */
13
abstract class QueueWorkerRunEvent extends Event
14
{
15
    /**
16
     * Subsystem name.
17
     *
18
     * @var string|null
19
     */
20
    private $subsystem;
21
    
22
    /**
23
     * Worker processing this request.
24
     * 
25
     * @var WorkerInterface
26
     */
27
    private $worker;
28
29
    /**
30
     * Class constructor.
31
     *
32
     * @param WorkerInterface $worker Worker processing this command.
33
     * @param string          $subsystem Subsystem name.
34
     */
35 8
    public function __construct(WorkerInterface $worker, $subsystem = null)
36
    {
37 8
        $this->worker = $worker;
38 8
        $this->subsystem = $subsystem ? (string) $subsystem : null;
39 8
    }
40
41
    /**
42
     * Get subsystem name.
43
     *
44
     * @return string|null
45
     */
46 2
    public function getSubsystem()
47
    {
48 2
        return $this->subsystem;
49
    }
50
    
51
    /**
52
     * Get worker processing this request.
53
     * 
54
     * @return WorkerInterface
55
     */
56 2
    public function getWorker()
57
    {
58 2
        return $this->worker;
59
    }
60
}
61