Completed
Push — master ( 859c70...b3ba31 )
by Matthew
06:19
created

Job::toMessage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Dtc\QueueBundle\RabbitMQ;
4
5
class Job extends \Dtc\QueueBundle\Model\MessageableJob
6
{
7
    protected $deliveryTag;
8
9
    /**
10
     * @return string
11
     */
12 2
    public function getDeliveryTag()
13
    {
14 2
        return $this->deliveryTag;
15
    }
16
17
    /**
18
     * @param mixed $deliveryTag
19
     */
20 7
    public function setDeliveryTag($deliveryTag)
21
    {
22 7
        $this->deliveryTag = $deliveryTag;
23 7
    }
24
25
    /**
26
     * @return string A json_encoded version of a queueable version of the object
27
     */
28 7
    public function toMessage()
29
    {
30 7
        $arr = $this->toMessageArray();
31 7
        $arr['id'] = $this->getId();
32
33 7
        return json_encode($arr);
34
    }
35
36
    /**
37
     * @param string $message a json_encoded version of the object
38
     */
39 7
    public function fromMessage($message)
40
    {
41 7
        $arr = json_decode($message, true);
42 7
        if (is_array($arr)) {
43 7
            $this->fromMessageArray($arr);
44 7
            if (isset($arr['id'])) {
45 7
                $this->setId($arr['id']);
46
            }
47
        }
48 7
    }
49
}
50