Completed
Pull Request — master (#9)
by Adam
15:12
created

AbstractMessage::handler()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 2
eloc 4
nc 2
nop 0
1
<?php
2
3
namespace Equip\Queue;
4
5
use Equip\Command\OptionsInterface;
6
use Equip\Command\OptionsSerializerTrait;
7
use Equip\Queue\Exception\MessageException;
8
9
abstract class AbstractMessage implements OptionsInterface
10
{
11
    /**
12
     * @var string
13
     */
14
    protected $command;
15
16
    /**
17
     * @var string
18
     */
19
    protected $handler;
20
21
    /**
22
     * @var string
23
     */
24
    protected $queue;
25
26
    /**
27
     * Returns the command class name
28
     *
29
     * @return string
30
     *
31
     * @throws MessageException If the command property isn't set
32
     */
33
    public function command()
34
    {
35
        if (!$this->command) {
36
            throw MessageException::missingProperty('command');
37
        }
38
39
        return $this->command;
40
    }
41
42
    /**
43
     * Returns the handler name
44
     *
45
     * @return string
46
     *
47
     * @throws MessageException If the handler property isn't set
48
     */
49
    public function handler()
50
    {
51
        if (!$this->handler) {
52
            throw MessageException::missingProperty('handler');
53
        }
54
55
        return $this->handler;
56
    }
57
58
    /**
59
     * Returns the queue name
60
     *
61
     * @return string
62
     *
63
     * @throws MessageException If the queue property isn't set
64
     */
65
    public function queue()
66
    {
67
        if (!$this->queue) {
68
            throw MessageException::missingProperty('queue');
69
        }
70
71
        return $this->queue;
72
    }
73
}
74