1 | <?php |
||
9 | class MessageMapper |
||
10 | { |
||
11 | /** |
||
12 | * @var Message |
||
13 | */ |
||
14 | protected $messagePrototype; |
||
15 | |||
16 | /** |
||
17 | * @return Message |
||
18 | */ |
||
19 | public function getMessagePrototype() |
||
20 | { |
||
21 | if (!$this->messagePrototype) { |
||
22 | $this->messagePrototype = new Message(); |
||
23 | } |
||
24 | return $this->messagePrototype; |
||
25 | } |
||
26 | |||
27 | /** |
||
28 | * @param Message $messagePrototype |
||
29 | * @return $this |
||
30 | */ |
||
31 | public function setMessagePrototype(Message $messagePrototype) |
||
32 | { |
||
33 | $this->messagePrototype = $messagePrototype; |
||
34 | return $this; |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * @param AMQPEnvelope $libMessage |
||
39 | * @return Message |
||
40 | */ |
||
41 | public function toMessage(AMQPEnvelope $libMessage) |
||
65 | } |
||
66 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: